Here i setup an mapping, queries and result:
https://gist.github.com/darklow/7964005
I also tried different queries, more simplified, without so much "nested" filters and queries (since in mapping i have include_in_parent: true nested is not required), but results all the time were same.
Does the following aggregation give back the result that you are expecting?
GET /movies/_search
{
"query": {
"nested": {
"path": "credits",
"query": {
"match": {
"credits.person_id": 1
}
}
}
},
"aggs": {
"credits" : {
"nested" : {
"path" : "credits"
},
"aggs" : {
"person_1" : {
"filter" : {
"term" : {
"person_id" : 1
}
},
"aggs" : {
"departments" : {
"terms" : {
"field" : "department"
}
}
}
}
}
}
}
}
For every match, the aggregator:
person_id: 1 ("person_1" aggregation)person_id: 1 ("department" aggregation)This resolved my issue and returned correct results. Apparently i used wrong syntax.
Thank you for explaining and giving full example. New aggregation feature is great!
Most helpful comment
Does the following aggregation give back the result that you are expecting?
For every match, the aggregator:
person_id: 1("person_1" aggregation)person_id: 1("department" aggregation)