Skip to content
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

[5.1] Fix sorting on scripted date and boolean fields #9285

Merged
merged 1 commit into from
Nov 30, 2016

Conversation

elastic-jasper
Copy link
Contributor

Fix sorting on scripted date and boolean fields

Backports PR #9261

Commit 1:
Fix sorting on scripted date and boolean fields

The elasticsearch API only supports2 sort scripts of type number and
string. Since dates need to be returned as millis since the epoch for
visualizations to work anyway, we can simply add a condition to send dates
as type number in the sort API. ES will cast booleans if we tell them
its a string, so we can add a similar condition there as well.

Fixes: #9257

Commit 2:
Add helpful comment

Backports PR #9261

**Commit 1:**
Fix sorting on scripted date and boolean fields

The elasticsearch API only [supports][1][2] sort scripts of type `number` and
`string`. Since dates need to be returned as millis since the epoch for
visualizations to work anyway, we can simply add a condition to send dates
as type number in the sort API. ES will cast booleans if we tell them
its a string, so we can add a similar condition there as well.

[1]: https://www.elastic.co/guide/en/elasticsearch/reference/5.0/search-request-sort.html#_script_based_sorting
[2]: https://github.com/elastic/elasticsearch/blob/aeb97ff41298e26b107a733837dfe17f123c0c9b/core/src/main/java/org/elasticsearch/search/sort/ScriptSortBuilder.java#L359

Fixes: #9257

* Original sha: 0d5a824
* Authored by Matthew Bargar <[email protected]> on 2016-11-29T21:05:48Z

**Commit 2:**
Add helpful comment

* Original sha: 14dc396
* Authored by Matthew Bargar <[email protected]> on 2016-11-30T21:02:41Z
@epixa epixa merged commit b5ae727 into 5.1 Nov 30, 2016
@epixa epixa deleted the jasper/backport/9261/5.1 branch November 30, 2016 21:15
airow pushed a commit to airow/kibana that referenced this pull request Feb 16, 2017
Backports PR elastic#9261

**Commit 1:**
Fix sorting on scripted date and boolean fields

The elasticsearch API only [supports][1][2] sort scripts of type `number` and
`string`. Since dates need to be returned as millis since the epoch for
visualizations to work anyway, we can simply add a condition to send dates
as type number in the sort API. ES will cast booleans if we tell them
its a string, so we can add a similar condition there as well.

[1]: https://www.elastic.co/guide/en/elasticsearch/reference/5.0/search-request-sort.html#_script_based_sorting
[2]: https://github.com/elastic/elasticsearch/blob/aeb97ff41298e26b107a733837dfe17f123c0c9b/core/src/main/java/org/elasticsearch/search/sort/ScriptSortBuilder.java#L359

Fixes: elastic#9257

* Original sha: 0d5a824
* Authored by Matthew Bargar <[email protected]> on 2016-11-29T21:05:48Z

**Commit 2:**
Add helpful comment

* Original sha: 14dc396
* Authored by Matthew Bargar <[email protected]> on 2016-11-30T21:02:41Z
Former-commit-id: b5ae727
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants