【发布时间】:2016-06-29 03:09:06
【问题描述】:
基于official document,似乎只能对单桶聚合进行排序。 如何按桶聚合数中的“平均”对结果进行排序?
我在 'result_1' 中添加了 'order' 仍然无法正常工作。 它显示以下错误:
TransportError(500, u'search_phase_execution_exception')
Invalid terms aggregation order path [reverse>condi_range>statistic_score.avg].
Terms buckets can only be sorted on a sub-aggregator path that is built out of zero or more single-bucket aggregations within the path and a final single-bucket or a metrics aggregation at the path end.
Sub-path [reverse>condi_range] points to non single-bucket aggregation')
关键是我必须限制“float_field”的范围,而range aggregation 是另一个桶聚合。
有人知道吗?
谢谢!
代码示例:
{
"aggs": {
"condi_nested": {
"aggs": {
"filtered": {
"filter": {
"bool": {}
},
"aggs": {
"result_1": {
"terms": {
"field": "Foo",
"size": 100000000,
"order": {
"reverse>condi_range>statistic_score.avg": "desc"
}
},
"aggs": {
"reverse": {
"aggs": {
"condi_range": {
"range": {
"ranges": [
{
"to": 100,
"from": 0
}
],
"field": "float_field"
},
"aggs": {
"percentile_score": {
"percentiles": {
"field": "float_field"
}
},
"statistic_score": {
"extended_stats": {
"field": "float_field"
}
}
}
}
},
"reverse_nested": {}
}
}
}
}
}
},
"nested": {
"path": "nested_path_of_Foo"
}
}
}
}
【问题讨论】:
标签: elasticsearch elasticsearch-aggregation