聚合排序无法正常工作
What were you trying to achieve? The aggregation sorting does not work correctly. It seems to try to sort the list by document count instead of filtering what I passed in. What action did you take? List aggregated values by sorting them by an average of aggregation results. Instead of sorting by aggregated value, it sorts by the count of documents in the group What action/response/output did you expect? { "status_group": { "buckets": [ { "avg_size": { "value": 3375.176470588235 }, "doc_count": 34, "key": 200, "key_as_string": "200" }, { "avg_size": { "value": 3311 }, "doc_count": 2, "key": 499, "key_as_string": "499" }, { "avg_size": { "value": 2832.5 }, "doc_count": 2, "key": 500, "key_as_string": "500" }, { "avg_size": { "value": 2225.3333333333335 }, "doc_count": 3, "key": 401, "key_as_string": "401" }, { "avg_size": { "value": 0 }, "doc_count": 1, "key": 302, "key_as_string": "302" } ] } } } What actually happened? { "status_group": { "buckets": [ { "avg_size": { "value": 3375.176470588235 }, "doc_count": 34, "key": 200, "key_as_string": "200" }, { "avg_size": { "value": 2225.3333333333335 }, "doc_count": 3, "key": 401, "key_as_string": "401" }, { "avg_size": { "value": 3311 }, "doc_count": 2, "key": 499, "key_as_string": "499" }, { "avg_size": { "value": 2832.5 }, "doc_count": 2, "key": 500, "key_as_string": "500" }, { "avg_size": { "value": 0 }, "doc_count": 1, "key": 302, "key_as_string": "302" } ] } } How to reproduce the issue? export ZINC_SEARCH_HOST='http://admin:dbbenchmarks@localhost:4080' curl "${ZINC_SEARCH_HOST}/es/_index_template" --data-binary @./template.json curl "${ZINC_SEARCH_HOST}/api/_bulk" --data-binary @./nginx.log curl -s "${ZINC_SEARCH_HOST}/es/logs10m/_search" -d '{"size":0,"aggs":{"status_group":{"terms":{"field":"status","size":20,"order":{"avg_size":"desc"}},"aggs":{"avg_size":{"avg":{"field":"size"}}}}}}' | jq .aggregations Which version of ZincSearch are you using? 0.4.10 Anything else that you can tell that will help us diagnose and resolve the issue efficiently? Any attachments/screenshots? nginx.log template.json Which service(s) is this relate to? API
内容来源: zincsearch/zincsearch