-
Notifications
You must be signed in to change notification settings - Fork 800
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
Search: Fix aggregation ordering in search results #8100
Conversation
Elasticsearch doesn’t guarantee the order of returned Aggregations will match the input order, which leads to unexpected behavior when rendering the Aggregations in the Widget. Adds code to re-order the Aggregation results to match the ordering as passed to `Jetpack_Search::set_filters()`. Fixes #8096
Can't we have the code doing the display just use the aggregation name rather than relying on the order? |
The internals of the Search code combines the originally specified Aggregations into the Aggregation results array, so that there is a single array that contains both the settings as specified in It would be possible to re-sort them at the Widget level, but it's better having them in the 'expected' order (as defined by site developer) everywhere, so it's consistent regardless of how the module is used - in both the Widget, but also any custom code that builds upon |
Also I should give a demo of the problem. Say you do this:
The Aggregations that get returned in the ES result aren't necessarily in the same order, so you could end up with an array like this:
Then when the Widget renders, the ordering is 'off' and it's not possible to control the display order. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh, I understand now. Thanks. LGTM
* Changelog 5.6: create base for changelog. * Update changelog with 5.5.1 info. * Changelog: add #7930 and #8238 * Changelog: add #8076 * Changelog: add #8100 * Changelog: add #8117 * Changelog: add #8141 * Changelog: add #8143 * Changelog: add #8147 * Changelog: add #8149 * Changelog: add #8153 * Changelog: add #8173 * Changelog: add #8184 * Changelog: add #8196 * Changelog: add #8199 * Changelog: add #8093 * Changelog: add #8171 * Changelog: add #8182 * Changelog: add #8202, #8222 * Changelog: add #8228 * Changelog: add #8240 * Changelog: add #8251 * remove AL card change
Elasticsearch doesn’t guarantee the order of returned Aggregations will
match the input order, which leads to unexpected behavior when
rendering the Aggregations in the Widget.
Adds code to re-order the Aggregation results to match the ordering as
passed to
Jetpack_Search::set_filters()
.Fixes #8096