Reverse nested aggregation parsing error

Hello,
I'm trying to use the new feature described here:
http://www.elasticsearch.org/guide/en/elasticsearch/reference/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/guide/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 elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/8e02b4aa-606a-477d-bb2a-e0e02ee9a7a9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

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 | @elasticsearchfr

Le 23 mai 2014 à 14:35:19, slagraulet@ippon.fr (slagraulet@ippon.fr) a écrit:

Hello,
I'm trying to use the new feature described here:
http://www.elasticsearch.org/guide/en/elasticsearch/reference/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/guide/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 elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/8e02b4aa-606a-477d-bb2a-e0e02ee9a7a9%40googlegroups.com.
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 elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/etPan.537f4476.71f32454.99d%40air-de-david.
For more options, visit https://groups.google.com/d/optout.

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 | @elasticsearchfrhttps://twitter.com/elasticsearchfr

Le 23 mai 2014 à 14:35:19, slagr...@ippon.fr <javascript:> (
slagr...@ippon.fr <javascript:>) a écrit:

Hello,
I'm trying to use the new feature described here:

Elasticsearch Platform — Find real-time answers at scale | Elastic

I have a structure similar to the one described in the nested aggregation
example :
Elasticsearch Platform — Find real-time answers at scale | Elastic
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 elasticsearc...@googlegroups.com <javascript:>.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/8e02b4aa-606a-477d-bb2a-e0e02ee9a7a9%40googlegroups.comhttps://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 elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/e24a0b30-dfea-4a2d-8591-4102fbafcc15%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

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 (
Add top_hits aggregation by martijnvg · Pull Request #6124 · elastic/elasticsearch · GitHub) 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, slagraulet@ippon.fr 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 | @elasticsearchfrhttps://twitter.com/elasticsearchfr

Le 23 mai 2014 à 14:35:19, slagr...@ippon.fr (slagr...@ippon.fr) a écrit:

Hello,
I'm trying to use the new feature described here:
Elasticsearch Platform — Find real-time answers at scale | Elastic
reference/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 : Elasticsearch Platform — Find real-time answers at scale | Elastic
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 elasticsearc...@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/
msgid/elasticsearch/8e02b4aa-606a-477d-bb2a-e0e02ee9a7a9%
40googlegroups.comhttps://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 elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/e24a0b30-dfea-4a2d-8591-4102fbafcc15%40googlegroups.comhttps://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 elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CAL6Z4j4q5PJ328EvK5XbKK21n8JmwNi7o6aHCP%2BrPbZdenAcdw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

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 (Add top_hits aggregation by martijnvg · Pull Request #6124 · elastic/elasticsearch · GitHub) 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, <slagr...@ippon.fr <javascript:>> 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 | @elasticsearchfrhttps://twitter.com/elasticsearchfr

Le 23 mai 2014 à 14:35:19, slagr...@ippon.fr (slagr...@ippon.fr) a
écrit:

Hello,
I'm trying to use the new feature described here:
Elasticsearch Platform — Find real-time answers at scale | Elastic
reference/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/
guide/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 elasticsearc...@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/
msgid/elasticsearch/8e02b4aa-606a-477d-bb2a-e0e02ee9a7a9%
40googlegroups.comhttps://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 elasticsearc...@googlegroups.com <javascript:>.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/e24a0b30-dfea-4a2d-8591-4102fbafcc15%40googlegroups.comhttps://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 elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/8644886c-3f48-4ae1-8c08-b4e78feeebc2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

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.(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:

Le vendredi 23 mai 2014 18:05:18 UTC+2, slagr...@ippon.fr 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 (Add top_hits aggregation by martijnvg · Pull Request #6124 · elastic/elasticsearch · GitHub) 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, slagr...@ippon.fr 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 | @elasticsearchfrhttps://twitter.com/elasticsearchfr

Le 23 mai 2014 à 14:35:19, slagr...@ippon.fr (slagr...@ippon.fr) a
écrit:

Hello,
I'm trying to use the new feature described here:
Elasticsearch Platform — Find real-time answers at scale | Elastic
reference/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/
guide/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 elasticsearc...@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/
msgid/elasticsearch/8e02b4aa-606a-477d-bb2a-e0e02ee9a7a9%
40googlegroups.comhttps://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 elasticsearc...@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/e24a0b30-dfea-4a2d-8591-4102fbafcc15%40googlegroups.comhttps://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 elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/ffe90554-8a54-45e9-8ee9-9457ffd658bf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

This is indeed a bug, thanks for sharing it! This should be easy to fix.

On 27 May 2014 11:35, slagraulet@ippon.fr 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.(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:

Le vendredi 23 mai 2014 18:05:18 UTC+2, slagr...@ippon.fr 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 (Add top_hits aggregation by martijnvg · Pull Request #6124 · elastic/elasticsearch · GitHub)
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, slagr...@ippon.fr 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, slagr...@ippon.fr (slagr...@ippon.fr) a
écrit:

Hello,
I'm trying to use the new feature described here:
Elasticsearch Platform — Find real-time answers at scale | Elastic
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 : Elasticsearch Platform — Find real-time answers at scale | Elastic
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 elasticsearc...@googlegroups.com.

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 elasticsearc...@googlegroups.com.
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 elasticsearch+unsubscribe@googlegroups.com.
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 elasticsearch+unsubscribe@googlegroups.com.
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.

Hi Stephan,

The bug has been fixed, can you try out a new build?

Martijn

On 30 May 2014 09:45, Martijn v Groningen martijn.v.groningen@gmail.com
wrote:

This is indeed a bug, thanks for sharing it! This should be easy to fix.

On 27 May 2014 11:35, slagraulet@ippon.fr 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.(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:

Le vendredi 23 mai 2014 18:05:18 UTC+2, slagr...@ippon.fr 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 (Add top_hits aggregation by martijnvg · Pull Request #6124 · elastic/elasticsearch · GitHub)
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, slagr...@ippon.fr 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, slagr...@ippon.fr (slagr...@ippon.fr) a
écrit:

Hello,
I'm trying to use the new feature described here:
Elasticsearch Platform — Find real-time answers at scale | Elastic
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 : Elasticsearch Platform — Find real-time answers at scale | Elastic
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 elasticsearc...@googlegroups.com.

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 elasticsearc...@googlegroups.com.
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 elasticsearch+unsubscribe@googlegroups.com.
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

--
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 elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CA%2BA76Tw5VGJuXF8hE4r98S3_--qA8Eps8kvvZ2Of53-Y%3DDmVFw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

I tried with this morning build and the filter aggregation now works on top
of the top_tag_hits aggregation.
We plan to thoroughly test this feature as we need it to be "feature
complete".

Thank you.

Le vendredi 30 mai 2014 12:43:50 UTC+2, Martijn v Groningen a écrit :

Hi Stephan,

The bug has been fixed, can you try out a new build?

Martijn

On 30 May 2014 09:45, Martijn v Groningen <martijn.v...@gmail.com
<javascript:>> wrote:

This is indeed a bug, thanks for sharing it! This should be easy to fix.

On 27 May 2014 11:35, <slagr...@ippon.fr <javascript:>> 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.(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:

Le vendredi 23 mai 2014 18:05:18 UTC+2, slagr...@ippon.fr 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 (Add top_hits aggregation by martijnvg · Pull Request #6124 · elastic/elasticsearch · GitHub)
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, slagr...@ippon.fr 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, slagr...@ippon.fr (slagr...@ippon.fr) a
écrit:

Hello,
I'm trying to use the new feature described here:
Elasticsearch Platform — Find real-time answers at scale | Elastic
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 : Elasticsearch Platform — Find real-time answers at scale | Elastic
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 elasticsearc...@googlegroups.com.

To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/8e02b4aa-606
a-477d-bb2a-e0e02ee9a7a9%40googlegroups.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 elasticsearc...@googlegroups.com.
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 elasticsearc...@googlegroups.com <javascript:>.
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

--
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 elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/2a795c59-e8ff-40cd-a2ca-51a7a9ef5b64%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.