Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
ankurgar opened this issue Oct 20, 2024 · 2 comments

Comments

@ankurgar
Copy link

ankurgar commented Oct 20, 2024

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

@ankurgar
Copy link
Author

Please help in validating the mentioned behavior issue, fix can be prioritized later on.

@ankurgar
Copy link
Author

@bsbodden - could you please vet this issue ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant