之前的话,排序,是按照每个bucket的doc_count降序来排的
但是假如说,我们现在统计出来每个颜色的电视的销售额,需要按照销售额升序排序????
搜索
{ "took": 2, "timed_out": false, "_shards": { "total": 5, "successful": 5, "failed": 0 }, "hits": { "total": 8, "max_score": 0, "hits": [] }, "aggregations": { "group_by_color": { "doc_count_error_upper_bound": 0, "sum_other_doc_count": 0, "buckets": [ { "key": "蓝色", "doc_count": 2, "avg_price": { "value": 2000 } }, { "key": "绿色", "doc_count": 2, "avg_price": { "value": 2100 } }, { "key": "红色", "doc_count": 4, "avg_price": { "value": 3250 } } ] } } } |
结果
{ "took": 2, "timed_out": false, "_shards": { "total": 5, "successful": 5, "failed": 0 }, "hits": { "total": 8, "max_score": 0, "hits": [] }, "aggregations": { "group_by_color": { "doc_count_error_upper_bound": 0, "sum_other_doc_count": 0, "buckets": [ { "key": "蓝色", "doc_count": 2, "avg_price": { "value": 2000 } }, { "key": "绿色", "doc_count": 2, "avg_price": { "value": 2100 } }, { "key": "红色", "doc_count": 4, "avg_price": { "value": 3250 } } ] } } } |