I am trying to write a query using query_string to retrieve data querying by nested objects.
An example of query I would like to do is this one:
{
"query": {
"query_string": {
"query": "a.id:2"
}
}
}
Where "a" is a nested object, and "id" is a field of "a".
I know I can successfully perform this task using using a nested query, writing a query like:
{
"nested": {
"path": "a"
"query_string": {
"query": "a.id:2"
}
}
}
However, I would like to avoid it. I don't want to figure out by myself that the user is searching for a nested field and modify the query. I tried to use the "fields" parameter, but it looks like it doesn't work with nested objects.
Is it possible to write this query directly using "query_string" queries? What semantic is it possible to obtain? (for instance, if I write "a.id:2 AND a.b:10" I am matching the two fields in the same object or in different objects?)