I need to do a nested query which tries to search within an array of objects. Apart from this, I have other parameters as well that I need to search upon. I am using filters for those. How can I combine the filters and nested query in an effective manner? Sorry I am not an expert on ES.
Here is the query I tried to execute in Kibana:
GET test-index/_search
{
"query": {
"bool": {
"filter": [
{
"term": {
"isPublic": true
}
},
{
"term": {
"isDeleted": false
}
}
]
},
"nested": {
"path": "data.location.countries",
"query": {
"bool": {
"must": [
{
"match": {
"data.location.countries.name": "United States"
}
},
{
"range": {
"data.location.countries.weight": {
"gt": 30
}
}
}
]
}
}
}
},
"size": "60",
"from": 0,
"sort": [
{
"followers": {
"order": "desc"
}
}
]
}
It returned with an error:
{
"error": {
"root_cause": [
{
"type": "parsing_exception",
"reason": "[bool] malformed query, expected [END_OBJECT] but found [FIELD_NAME]",
"line": 17,
"col": 5
}
],
"type": "parsing_exception",
"reason": "[bool] malformed query, expected [END_OBJECT] but found [FIELD_NAME]",
"line": 17,
"col": 5
},
"status": 400
}
Can someone shed some knowledge on this?