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, [email protected] ([email protected]) 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 [email protected].
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 [email protected].
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.