-
Notifications
You must be signed in to change notification settings - Fork 25k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to sort by result of bucket script aggregation #32153
Comments
Pinging @elastic/es-search-aggs |
Hi @ydzhu, in a It's not good that we're throwing a 503, and the error message is also misleading. We're tracking the error code issue in #20003. I don't see an easy workaround for your request, but tagging @polyfractal just in case he has an idea. |
@jtibshirani is correct, you can't sort by pipeline aggs... they are executed after regular aggs execute. If the terms agg contains all the entries you care about, you can still do pipeline sorting using the The caveat is that this performs sorting on the final list of buckets, not while the aggregations are calculating. So it only sorts the list that is returned by the It'd look something like this (untested):
|
I opened #32522 in hopes of clarifying the error message. I'll close this out once that goes in. |
So is there any other option to sort buckets based metric, calculated from sub-aggregations results? |
I get result by using bucket script aggregation, but I can't sort by this aggregation value. For explame,
I hope sort by "avg_time" that is calculated by bucket_script, so I add order in term aggregation ( "order": {"avg_time": "desc"}). But it cause error. This reason of error is “Invalid aggregator order path [avg_time]. Unknown aggregation [avg_time]".
Even more puzzling is I use add order by sum_count instead of avg_time, i can get correct value.
The text was updated successfully, but these errors were encountered: