We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
When we have a nested object structure like the following (getter and setter omitted):
@Document(indexName = "cities") class City { @Id private String name; @Field(type = FieldType.Nested) private Collection<House> houses = new ArrayList<>(); } class House { @Field(type = FieldType.Text) private String street; @Field(type = FieldType.Text) private String streetNumber; @Field(type = FieldType.Nested) private List<Inhabitant> inhabitants = new ArrayList<>(); } class Inhabitant { @Field(type = FieldType.Text) private String firstName; @Field(type = FieldType.Text) private String lastName; }
CriteriaQuery should be able to search for cities, houses and persons like this:
CriteriaQuery
CriteriaQuery cityQuery = new CriteriaQuery(new Criteria("name").is("london")) CriteriaQuery houseQuery = new CriteriaQuery(new Criteria("houses.street").is("baker")) CriteriaQuery personQuery = new CriteriaQuery(new Criteria("houses.inhabitants.lastName").is("holmes"))
This currently works for the first case, but not the others. The created queries that are sent to elasticsearch are:
{ "query": { "bool": { "must": [ { "query_string": { "query": "london", "fields": [ "name" ] } } ] } } }
{ "query": { "bool": { "must": [ { "query_string": { "query": "baker", "fields": [ "houses.street" ] } } ] } } }
{ "query": { "bool": { "must": [ { "query_string": { "query": "holmes", "fields": [ "houses.inhabitants.lastName" ] } } ] } } }
For the second and third case a nested query specifying the nested path must be constructed:
{ "query": { "nested": { "path": "houses", "query": { "bool": { "must": [ { "query_string": { "query": "baker", "fields": [ "houses.street" ] } } ] } } } } }
{ "query": { "nested": { "path": "houses.inhabitants", "query": { "bool": { "must": [ { "query_string": { "query": "barone", "fields": [ "houses.inhabitants.lastName" ] } } ] } } } } }
CriteriaQueryProcessor must be adapted to provide these nested queries.
CriteriaQueryProcessor
Also see #1752 and https://stackoverflow.com/questions/66637914/how-to-construct-nested-query-using-criteria-and-criteriaquery-in-spring-data-el for the same issue
The text was updated successfully, but these errors were encountered:
2bd4ef7
sothawo
Successfully merging a pull request may close this issue.
When we have a nested object structure like the following (getter and setter omitted):
CriteriaQuery
should be able to search for cities, houses and persons like this:This currently works for the first case, but not the others. The created queries that are sent to elasticsearch are:
For the second and third case a nested query specifying the nested path must be constructed:
CriteriaQueryProcessor
must be adapted to provide these nested queries.Also see #1752 and https://stackoverflow.com/questions/66637914/how-to-construct-nested-query-using-criteria-and-criteriaquery-in-spring-data-el for the same issue
The text was updated successfully, but these errors were encountered: