I have a parent/child relationship and I need to filter children based on parent ID and child properties. However, I can filter children by parent ID but I can not filter by any child properties.
Here is my search:
{
"query": {
"bool": {
"should": [
{
"match": {
"name": "beer"
}
}
],
"must": [
{
"has_parent": {
"type": "pubs",
"score_mode": "score",
"query": {
"ids": {
"values": ["AVx3Ruk03JWWfjjJokHs"]
}
}
}
}
]
}
}
}
But I was given results like this:
{
"took": 98,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 1,
"max_score": 0.5,
"hits": [
{
"_index": "wildwest",
"_type": "drinks",
"_id": "AVx3Xc8g3JWWfjjJokHx",
"_score": 0.5,
"_routing": "AVx3Ruk03JWWfjjJokHs",
"_parent": "AVx3Ruk03JWWfjjJokHs",
"_source": {
"name": "Milk",
"description": "Milk description",
"unit_price": 2.9,
"amount": 20
}
}
]
}
}
What am I doing wrong? I'm using Elasticsearch 2.4.
NOTE: I tried to put all filters inside should query, but I was given drinks from another pub. Changing to must query nothing is returned.