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

Support year units in date math expressions #3828

Closed
apidruchny opened this Issue Oct 3, 2013 · 6 comments

Comments

Projects
None yet
2 participants
@apidruchny
Copy link

apidruchny commented Oct 3, 2013

According to http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/mapping-date-format.html, the date math expressions support M (month), w (week), h (hour), m (minute), and s (second) units. Why years are not supported? Please add support for year units.

@dadoonet

This comment has been minimized.

Copy link
Member

dadoonet commented Oct 3, 2013

Agree. See also #2473.

@ghost ghost assigned dadoonet Oct 7, 2013

@dadoonet

This comment has been minimized.

Copy link
Member

dadoonet commented Oct 7, 2013

The more I think about it the more I can't find a right way to support it. What duration in milliseconds should correspond to a year?

365 * 24 * 60 * 60 * 1000 ?

What about leap years?

As there is no way to have an exact value, I don't think we should support it.

That said, you can define a year using 365d or 366d.

@apidruchny

This comment has been minimized.

Copy link
Author

apidruchny commented Oct 7, 2013

David, I am looking at the commit that added the date math support originally: f997315
There is no need to know the duration of the year in milliseconds, because org.joda.time.MutableDateTime methods are used for other units, for example, addMonths(). This class also support years, it has methods like year() and addYears(). Am I missing something?

@dadoonet

This comment has been minimized.

Copy link
Member

dadoonet commented Oct 7, 2013

I think I was wrong here. I was mixing date histogram facet concern and your original concern.

subhash added a commit to subhash/elasticsearch that referenced this issue Oct 10, 2013

@dadoonet dadoonet closed this in b758b76 Oct 11, 2013

dadoonet added a commit that referenced this issue Oct 11, 2013

Support year units in date math expressions
According to http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/mapping-date-format.html, the date math expressions support M (month), w (week), h (hour), m (minute), and s (second) units. Why years are not supported? Please add support for year units.

Closes #3828.
Closes #3874.
@apidruchny

This comment has been minimized.

Copy link
Author

apidruchny commented Oct 29, 2013

Thanks all. I am looking forward to release 0.90.6 to be able to use this feature.

@apidruchny

This comment has been minimized.

Copy link
Author

apidruchny commented Oct 30, 2013

By the way, the day unit is supported. The documentation should be updated. The sentence:
The units supported are y (year), M (month), w (week), h (hour), m (minute), and s (second). should be The units supported are y (year), M (month), w (week), d (day), h (hour), m (minute), and s (second).
The next paragraph in the documentation even shows samples of rounding by day.

mute pushed a commit to mute/elasticsearch that referenced this issue Jul 29, 2015

Support year units in date math expressions
According to http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/mapping-date-format.html, the date math expressions support M (month), w (week), h (hour), m (minute), and s (second) units. Why years are not supported? Please add support for year units.

Closes elastic#3828.
Closes elastic#3874.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.