Hi, 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". > > Thanks for your suggestions and insights. > > A. > > > > -- 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+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/e122e8c9-c0df-4d6b-b91c-0b208d4e5e2e%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.