Is it possible to aggregate only on the nested documents that are returned
by a (filtered) query? For what I can tell when using a nested aggregation,
it will function on all nested documents of the parent documents whose
nested document satisfy a nested query/filter. Did that make sense? Is
this the same limitation as issue #3022? I know that number by heart by now.
For example, I have 3 simple documents, where the nstd object is defined as
nested:
{
"name" : "foo",
"nstd" : [
{
"ID" : 1
}
]
}
'
{
"name" : "bar",
"nstd" : [
{
"ID" : 2
}
]
}
'
{
"name" : "baz",
"nstd" : [
{
"ID" : 1
},
{
"ID" : 2
}
]
}
'
I then execute a simple nested query:
"query": {
"filtered": {
"query": {
"match_all": {}
},
"filter": {
"nested": {
"path": "nstd",
"filter": {
"term": {
"nstd.ID": 1
}
}
}
}
}
}
If I aggregate on the nstd.ID field, I will always get back results for
nested documents that were excluded by the filter:
"buckets": [
{
"key": 1,
"doc_count": 2
},
{
"key": 2,
"doc_count": 1
}
]
Since the ID:2 field does not match the filter, it should not be returned
with the aggregation. I have tried using a filter aggregation with the same
filter used in the filtered query, but I receive the same results.
Cheers,
Ivan
--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CALY%3DcQBsrKGntY-WT1PWZbTynxFvfw%2BYc7K2Q7a8NX3ive7t2w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.