My structure:
Person: type object.
Person.Cars: type nested.
Person.Cars.Radios: type nested.
I want to write a query that should find all person with:
- Car X
- Car year from 40 to 100
- Radio in the car Y
{ "query": { "nested": { "path": "person.cars", "query": { "bool": { "filter": [ { "match": { "person.cars.id": { "query": "X" } } }, { "range": { "person.cars.year": { "from": 40, "to": 100 } } } ] }, "nested": { "path": "person.cars.radios", "query": { "bool": { "filter": [ { "match": { "person.cars.radios.id": { "query": "Y" } } } ] } } } } } } }
My response:
{
"error": {
"root_cause": [
{
"type": "parsing_exception",
"reason": "[bool] malformed query, expected [END_OBJECT] but found [FIELD_NAME]",
"line": 26,
"col": 5
}
],
"type": "parsing_exception",
"reason": "[bool] malformed query, expected [END_OBJECT] but found [FIELD_NAME]",
"line": 26,
"col": 5
},
"status": 400
}
How to write query like this? I know that I have to move my second nested part, but I don't know how.