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

Make dates be ReadableDateTimes in scripts #22948

Merged
merged 2 commits into from
Feb 6, 2017

Conversation

nik9000
Copy link
Member

@nik9000 nik9000 commented Feb 3, 2017

Instead of longs. If you want millis since epoch you can call doc.date_field.value.millis.

Relates to #22875

@nik9000 nik9000 added :Core/Infra/Scripting Scripting abstractions, Painless, and Mustache >breaking >enhancement v6.0.0-alpha1 labels Feb 3, 2017
@nik9000 nik9000 requested a review from rjernst February 3, 2017 02:23
@nik9000
Copy link
Member Author

nik9000 commented Feb 3, 2017

@rjernst, would you like to look at this? It is the second step we discussed in #22875 (comment).

Copy link
Member

@rjernst rjernst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

// that scripts return the same internal representation as regular fields, so boolean
// values in scripts need to be converted to a number, and the value formatter will
// make sure of using true/false in the key_as_string field
return ((Boolean) o).booleanValue() ? 1.0 : 0.0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just a bonus fix, unrelated to the date change right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed - bonus to make this line up with toLongValue.


==== Date fields now return dates

`doc.some_date_field.value` now returns `ReadableDateTime`s instead of
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to link ReadableDateTime here to the generated painless docs?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure!

Copy link
Member Author

@nik9000 nik9000 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given this conversation I don't think we're done here but I still think this is a step in the right direction so I'm going to retest locally and merge.

// that scripts return the same internal representation as regular fields, so boolean
// values in scripts need to be converted to a number, and the value formatter will
// make sure of using true/false in the key_as_string field
return ((Boolean) o).booleanValue() ? 1.0 : 0.0;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed - bonus to make this line up with toLongValue.


==== Date fields now return dates

`doc.some_date_field.value` now returns `ReadableDateTime`s instead of
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure!

@nik9000 nik9000 merged commit 0d6e622 into elastic:master Feb 6, 2017
@nik9000
Copy link
Member Author

nik9000 commented Feb 6, 2017

master: 0d6e622

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>breaking :Core/Infra/Scripting Scripting abstractions, Painless, and Mustache >enhancement v6.0.0-alpha1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants