-
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
[Rollup] Ordering by sub-agg fails due to name rewriting #30467
Comments
Pinging @elastic/es-search-aggs |
hi @polyfractal ,we're testing the rollup feature on es 6.3.2. I found max/min sub-aggs can be used in orderby, but avg still not work. Do we plan to fix this? |
@zhuhuizj I looked into this the other day, and I'm afraid there's no quick fix for sorting the What we need is an average aggregator that can extract the count from the document, instead of just incrementing the count for each value. That way we could perform the avg in a single agg instead of two like today, and it'd also allow us to sort. A while back, I merged a new In either case, we have a tentative plan but need to find time to work on it. |
I see. thanks for your response:) |
No problem! We'll ping this thread if we have any progress or updates to share, so feel free to subscribe to it for updates. |
Closing as this is unlikely to be resolved with v1, and will be a non-issue with rollup v2 |
If an aggregation tries to order by a sub-aggregation, RollupSearch will fail because we rewrite the aggregation name internally (
foo
might be rewritten tofoo.max.value
). For example:Will throw:
This is trivially fixable for most of the metrics, we just need to do the rewriting. I'm not quite sure how this will work for averages though, since an avg == two metrics which we re-combine. We can't order by either agg individually since it only contains half the information, and if we order after the recombination we may be missing the "best" buckets.
The only saving grace is that ordering by sub-agg is discouraged anyway as count errors are unbounded, so this isn't really any worse. Ordering by sub-agg is as good as rolling dice :)
I've been wanting to look into modifying
avg
to accept "arbitrary" counts from the doc (instead of just incrementing the counter), so perhaps this is another motivation to do so./cc @cdahlqvist
The text was updated successfully, but these errors were encountered: