When implementing a custom aggregation: can I access the result documents
in my aggregator so that I can skip result documents based on it's
properties?
To make it clearer I explain
I have an index "products" that contains "product" documents. A product
contains a nested collection of "variant" documents.
The requirements is to have a query that return "variant" documents. Kind
of a "Nested Aggregation".
To complicate things: not all "variants" should be returned. Some dynamic
filtering has to be applied. And this filtering depends on properties of
the nested "variant" documents. I need to peek at all variants contained in
a product in order to determine if a variant should be included in the
result or not.
I am thinking that I could accomplish this writing a plugin which contains
the custom aggregation when my initial question could be answered with
"yes".
I think you should be able to achieve the functionality you need without
writing a custom aggregation. If you use a combination of the filter
aggregation wrapped in a nested aggregation then you should be able to
filter the child documents ("variant") before they are returned. Then if
you want to return the top X 'variants' you can use the top_hits
aggregation as a sub-aggregation of the filter aggregation.
Hope this helps,
Colin
On Thursday, 20 November 2014 11:51:40 UTC, AndyP wrote:
When implementing a custom aggregation: can I access the result documents
in my aggregator so that I can skip result documents based on it's
properties?
To make it clearer I explain
I have an index "products" that contains "product" documents. A product
contains a nested collection of "variant" documents.
The requirements is to have a query that return "variant" documents. Kind
of a "Nested Aggregation".
To complicate things: not all "variants" should be returned. Some dynamic
filtering has to be applied. And this filtering depends on properties of
the nested "variant" documents. I need to peek at all variants contained in
a product in order to determine if a variant should be included in the
result or not.
I am thinking that I could accomplish this writing a plugin which contains
the custom aggregation when my initial question could be answered with
"yes".
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.