This is indeed a bug, thanks for sharing it! This should be easy to fix.
On 27 May 2014 11:35, <[email protected]> wrote: > Hello, > I tried the new top_hots aggregation and made it work on denormalized data. > > However, when I tries to add a filter I ran into the following exception: > > [2014-05-27 11:32:12,869][DEBUG][action.search.type ] [Cap 'N Hawk] > failed to reduce search > org.elasticsearch.action.search.ReduceSearchPhaseException: Failed to > execute phase [fetch], [reduce] > at > org.elasticsearch.action.search.type.TransportSearchQueryThenFetchAction$AsyncAction.finishHim(TransportSearchQueryThenFetchAction.java:141) > at > org.elasticsearch.action.search.type.TransportSearchQueryThenFetchAction$AsyncAction$1.onResult(TransportSearchQueryThenFetchAction.java:113) > at > org.elasticsearch.action.search.type.TransportSearchQueryThenFetchAction$AsyncAction$1.onResult(TransportSearchQueryThenFetchAction.java:107) > at > org.elasticsearch.search.action.SearchServiceTransportAction$23.run(SearchServiceTransportAction.java:526) > at > java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) > at > java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) > at java.lang.Thread.run(Thread.java:745) > Caused by: java.lang.NullPointerException > at > org.apache.lucene.search.TopDocs$ScoreMergeSortQueue.<init>(TopDocs.java:89) > at org.apache.lucene.search.TopDocs.merge(TopDocs.java:219) > at org.apache.lucene.search.TopDocs.merge(TopDocs.java:209) > at > org.elasticsearch.search.aggregations.bucket.tophits.InternalTopHits.reduce(InternalTopHits.java:107) > at > org.elasticsearch.search.aggregations.InternalAggregations.reduce(InternalAggregations.java:146) > at > org.elasticsearch.search.aggregations.bucket.InternalSingleBucketAggregation.reduce(InternalSingleBucketAggregation.java:82) > at > org.elasticsearch.search.aggregations.InternalAggregations.reduce(InternalAggregations.java:146) > at > org.elasticsearch.search.aggregations.bucket.terms.InternalTerms$Bucket.reduce(InternalTerms.java:77) > at > org.elasticsearch.search.aggregations.bucket.terms.InternalTerms.reduce(InternalTerms.java:157) > at > org.elasticsearch.search.aggregations.bucket.terms.InternalTerms.reduce(InternalTerms.java:37) > at > org.elasticsearch.search.aggregations.InternalAggregations.reduce(InternalAggregations.java:146) > at > org.elasticsearch.search.controller.SearchPhaseController.merge(SearchPhaseController.java:386) > at > org.elasticsearch.action.search.type.TransportSearchQueryThenFetchAction$AsyncAction.innerFinishHim(TransportSearchQueryThenFetchAction.java:152) > at > org.elasticsearch.action.search.type.TransportSearchQueryThenFetchAction$AsyncAction.finishHim(TransportSearchQueryThenFetchAction.java:139) > ... 6 more > > > Here are the gists used to create the data: > > - mapping : https://gist.github.com/stephlag/f9402c699374438c3ede > - data: https://gist.github.com/stephlag/ecb5b2dc384a3f07602d > - queries: https://gist.github.com/stephlag/7ad8edf1ab6b757be3b3 > > > > Le vendredi 23 mai 2014 18:05:18 UTC+2, [email protected] a écrit : > >> Thank you >> I see this pull request is now merged on the 1.3 branch so I will try >> this feature to see if it fits our needs. >> >> Le vendredi 23 mai 2014 15:49:51 UTC+2, Adrien Grand a écrit : >>> >>> You might want to do the innermost aggregation using the _uid field >>> instead of the _id field since the latter is not indexed by default. The >>> next version of Elasticsearch will feature a new aggregation called >>> top_hits (https://github.com/elasticsearch/elasticsearch/pull/6124) >>> that will allow to get the top hits per bucket. I think this is what you >>> are looking for? >>> >>> >>> On Fri, May 23, 2014 at 3:26 PM, <[email protected]> wrote: >>> >>>> Hello David, >>>> >>>> The query you gave me is correct, I don't have the parsing error >>>> anymore. >>>> >>>> Unfortunately, it does not give the result I expected. >>>> What I'm trying to get is a minimum price for each of the products, >>>> which is an aggregation for each of the products retrieved from the query. >>>> >>>> Do you have any advice on how to achieve this ? >>>> >>>> Thank you >>>> >>>> Le vendredi 23 mai 2014 14:52:23 UTC+2, David Pilato a écrit : >>>>> >>>>> I think your syntax is incorrect here. It should be something like: >>>>> >>>>> >>>>> GET /products/_search >>>>> { >>>>> "query": { >>>>> "match_all": {} >>>>> }, >>>>> "aggs": { >>>>> "offers": { >>>>> "nested": { >>>>> "path": "offers" >>>>> }, >>>>> "aggs": { >>>>> "min_price": { >>>>> "min": { >>>>> "field": "offers.price" >>>>> } >>>>> }, >>>>> "offers_to_product": { >>>>> "reverse_nested": { >>>>> "path": "offers" >>>>> }, >>>>> "aggs": { >>>>> "productId_per_offer": { >>>>> "terms": { >>>>> "field": "id" >>>>> } >>>>> } >>>>> } >>>>> } >>>>> } >>>>> } >>>>> } >>>>> } >>>>> >>>>> Not tested though. >>>>> >>>>> Note that offers_to_product is an aggs at the same level as min_price. >>>>> >>>>> -- >>>>> *David Pilato* | *Technical Advocate* | *Elasticsearch.com* >>>>> @dadoonet <https://twitter.com/dadoonet> | @elasticsearchfr >>>>> <https://twitter.com/elasticsearchfr> >>>>> >>>>> >>>>> Le 23 mai 2014 à 14:35:19, [email protected] ([email protected]) a >>>>> écrit: >>>>> >>>>> Hello, >>>>> I'm trying to use the new feature described here: >>>>> http://www.elasticsearch.org/guide/en/elasticsearch/referenc >>>>> e/current/search-aggregations-bucket-reverse-nested-aggregation.html# >>>>> search-aggregations-bucket-reverse-nested-aggregation >>>>> >>>>> I have a structure similar to the one described in the nested >>>>> aggregation example : http://www.elasticsearch.org/g >>>>> uide/en/elasticsearch/reference/current/search-aggregations- >>>>> bucket-nested-aggregation.html >>>>> For one product I have several resellers so I want to know the minimum >>>>> price for each product. >>>>> >>>>> I tried this search, similar to the documentation example: >>>>> GET /products/_search >>>>> { >>>>> "query": { >>>>> "match_all": {} >>>>> }, >>>>> "aggs": { >>>>> "offers": { >>>>> "nested": { >>>>> "path": "offers" >>>>> }, >>>>> "aggs": { >>>>> "min_price": { >>>>> "min": { >>>>> "field": "offers.price" >>>>> } >>>>> }, >>>>> "aggs": { >>>>> "offers_to_product": { >>>>> "reverse_nested": { >>>>> "path": "offers" >>>>> }, >>>>> "aggs": { >>>>> "productId_per_offer": { >>>>> "terms": { >>>>> "field": "id" >>>>> } >>>>> } >>>>> } >>>>> } >>>>> } >>>>> } >>>>> } >>>>> } >>>>> } >>>>> >>>>> I have a parsing error: >>>>> Caused by: org.elasticsearch.search.SearchParseException: >>>>> [products][4]: query[ConstantScore(*:*)],from[-1],size[-1]: Parse >>>>> Failure [Could not find aggregator type [offers_to_product] in [aggs]] >>>>> at org.elasticsearch.search.aggregations.AggregatorParsers. >>>>> parseAggregators(AggregatorParsers.java:128) >>>>> at org.elasticsearch.search.aggregations.AggregatorParsers. >>>>> parseAggregators(AggregatorParsers.java:120) >>>>> at org.elasticsearch.search.aggregations.AggregatorParsers. >>>>> parseAggregators(AggregatorParsers.java:77) >>>>> at org.elasticsearch.search.aggregations. >>>>> AggregationParseElement.parse(AggregationParseElement.java:60) >>>>> >>>>> What is wrong with my request? >>>>> >>>>> Thank you, >>>>> Stephan >>>>> -- >>>>> 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 [email protected]. >>>>> >>>>> To view this discussion on the web visit https://groups.google.com/d/ >>>>> msgid/elasticsearch/8e02b4aa-606a-477d-bb2a-e0e02ee9a7a9%40goo >>>>> glegroups.com >>>>> <https://groups.google.com/d/msgid/elasticsearch/8e02b4aa-606a-477d-bb2a-e0e02ee9a7a9%40googlegroups.com?utm_medium=email&utm_source=footer> >>>>> . >>>>> For more options, visit https://groups.google.com/d/optout. >>>>> >>>>> -- >>>> 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 [email protected]. >>>> To view this discussion on the web visit https://groups.google.com/d/ >>>> msgid/elasticsearch/e24a0b30-dfea-4a2d-8591-4102fbafcc15% >>>> 40googlegroups.com >>>> <https://groups.google.com/d/msgid/elasticsearch/e24a0b30-dfea-4a2d-8591-4102fbafcc15%40googlegroups.com?utm_medium=email&utm_source=footer> >>>> . >>>> >>>> For more options, visit https://groups.google.com/d/optout. >>>> >>> >>> >>> >>> -- >>> Adrien Grand >>> >> -- > 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 [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/elasticsearch/ffe90554-8a54-45e9-8ee9-9457ffd658bf%40googlegroups.com > <https://groups.google.com/d/msgid/elasticsearch/ffe90554-8a54-45e9-8ee9-9457ffd658bf%40googlegroups.com?utm_medium=email&utm_source=footer> > . > > For more options, visit https://groups.google.com/d/optout. > -- Met vriendelijke groet, Martijn van Groningen -- 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 [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CA%2BA76TzTDwv8W4Mv%3DVB%3DfK7kPPUrL%2BMZGwzxCU_Tb9td9B6SMw%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
