-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Add numeric_type option for correct sort order on mixed date and date_nanos fields #44212
Add numeric_type option for correct sort order on mixed date and date_nanos fields #44212
Conversation
💔 Build Failed |
…-sort-on-mixed-date-and-date_nanos
💔 Build Failed |
…hub.com:kertal/kibana into kertal-pr-fix-sort-on-mixed-date-and-date_nanos
…t-on-mixed-date-and-date_nanos
💚 Build Succeeded |
…t-on-mixed-date-and-date_nanos
…t-on-mixed-date-and-date_nanos
src/legacy/core_plugins/kibana/public/discover/doc_table/lib/get_sort.js
Outdated
Show resolved
Hide resolved
💔 Build Failed |
💔 Build Failed |
…t-on-mixed-date-and-date_nanos
💔 Build Failed |
💚 Build Succeeded |
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.
The code looks and testing this in Chrome (I had to change my timezone to Europe/Athens from America/Phoenix), the fix works as expected.
@kertal is there an issue for the timezone bug with 'America/Phoenix' registering date nano timestamps as before epoch time?
order: sortPair[timeFieldName], | ||
numeric_type: 'date_nanos' | ||
} | ||
}); |
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.
Could we move this code into the getSort
function itself? getSort
is used in the search panel in Dashboard as well so I suspect putting this in the Discover controller means the sorting still won't work in Dashboard.
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.
Thanks Bargs, yes this needs to be adapted , I already did . I initially built this in the getSort
function, but this broke functionality like changing the sort order in the doc table. So I thought, better add this change before setting the sort
of searchSource
, since it's only relevant for Elasticsearch. Now I've extracted this to a separate function getSortForSearchSource
, adapted also for dashboard. works
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.
dear @Bargs, is that change ok for you? merci!
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.
Sorry, I could have sworn I left a comment on this right after you made the changes. Must have forgot to hit submit. Yeah, LGTM
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.
great, thx!
…t-on-mixed-date-and-date_nanos
👍 Tina, yes, there's an ElasticSearch issue, I'll ask when aggregation with date_nanos will work worldwide |
💔 Build Failed |
@TinaHeiligers here's the ES issue elastic/elasticsearch#39107 |
…t-on-mixed-date-and-date_nanos
💚 Build Succeeded |
…_nanos fields (elastic#44212) * Implement getSortForSearchSource for add-on of 'numeric_type' to the ES request. Then sorting on a field that can be of date or date_nanos type works correctly * Add functional test
Summary
When you are searching multiple indices and they are using a mix of
date
anddate_nanos
, the sort order is not correct. The reason is that the internal representation is a long since the start of the epoche for both, but because of the different precision this doesn't sort correctly. Elasticsearch has added a workaround for that in 7.2 with an option "numeric_type": "date_nanos" to cast everything to nanosecond precision. This PR adds this option for searches withinDiscover
.Steps to reproduce:
Fixes #43939
Checklist
Use
strikethroughsto remove checklist items you don't feel are applicable to this PR.- [ ] This was checked for cross-browser compatibility, including a check against IE11- [ ] Any text added follows EUI's writing guidelines, uses sentence case text and includes i18n support- [ ] Documentation was added for features that require explanation or tutorials- [ ] This was checked for keyboard-only and screenreader accessibilityFor maintainers
- [ ] This was checked for breaking API changes and was labeled appropriately