根据官方文档,似乎只能对单桶聚合进行排序。如何按桶聚合数量中的“平均”对结果进行排序?
我在 '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'的范围,范围聚合是另一个桶聚合。
有人有什么主意吗?
谢谢!
代码示例:
{
"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"
}
}
}
}