Skip to content

@Indexed(SchemaFieldType.NESTED) does not work for JSONArray or List<Model> data types. #519

Open
@ankurgar

Description

@ankurgar

Document class -

@Data
@RequiredArgsConstructor(staticName = "of")
@AllArgsConstructor(access = AccessLevel.PROTECTED)
@Document(value = "cmpny:")
@IndexingOptions(indexName = "idx:company", creationMode = IndexCreationMode.DROP_AND_RECREATE)
class Company {
  @Id
  private String id;

  @Indexed(schemaFieldType = SchemaFieldType.TAG, sortable = true)
  private Set<String> tags = new HashSet<String>();

  /**
   * It does not creates the index on nested fields within Phones class.
   */
  @Indexed(schemaFieldType = SchemaFieldType.NESTED, sortable = false)
  private List<Phones> phonesList;

  // Below one works for nested fields within address.
  @Indexed(schemaFieldType = SchemaFieldType.NESTED, sortable = false)
  private Address address;
}

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class Phones {

  @Indexed(schemaFieldType = SchemaFieldType.TAG, sortable = true)
  private String number;
}


@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class Address {

  @Indexed(schemaFieldType = SchemaFieldType.TAG, sortable = true)
  private String city;

}

Upon executing with @EnableRedisDocumentRepositories(basePackages = "com.ecs.sgws.poc.romsdocuments.model"), it generates index for all fields except for List of Phones.

Below is the index info snapshot using FT.INFO idx:company
Screenshot 2024-10-20 at 18 06 28

Expectation was to also get $.phonesList[*].number indexed but it did not get indexed. Right now we are defining schema in explicit manner (no declarative).

Please kindly add support for indexing json array kind of elements in declarative manner.

PS : Since json array is not supported in declarative manner, we also have a hunch that search result serialization might not also work with it, as see a similar code logic for projection fields - https://github.com/redis/redis-om-spring/blob/main/redis-om-spring/src/main/java/com/redis/om/spring/search/stream/SearchStreamImpl.java#L558

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions