elastic / elasticsearch

Free and Open Source, Distributed, RESTful Search Engine
https://www.elastic.co/products/elasticsearch
Other
69.93k stars 24.74k forks source link

using Persian (Jalali) calendar #96938

Closed nevahid closed 1 year ago

nevahid commented 1 year ago

Description

Hi, is it possible to change the default date system from Gregorian to Jalali (Persian) date system? If it's possible how can we achieve it? where should we start? thanks in advance

elasticsearchmachine commented 1 year ago

Pinging @elastic/es-core-infra (Team:Core/Infra)

thecoop commented 1 year ago

I'm afraid Java does not have built-in support for the Jalali calendar, and as such we don't support it directly. Doing so would require pulling in a 3rd-party library such as https://github.com/amirmehdizadeh/JalaliCalendar, and integrating that into elasticsearch and kibana.

However, it may be quite a bit of work, as there are likely some significant assumptions made in the code that its using the Gregorian calendar (the only calendar natively supported by the JVM).

It also depends on what exactly you wish to change - is it just how dates are displayed, or more built-in operations like calendar operations in Painless?

nevahid commented 1 year ago

Firstly thanks for your response :-) what we want to achieve is being able to show dates in Jalali calendar system, moreover we need it for monthly queries so that clients can see data grouped by monthly times (of course in Jalali calendar)

thecoop commented 1 year ago

It's possible you could get the output you need by converting the code used in https://github.com/amirmehdizadeh/JalaliCalendar/blob/master/src/main/java/com/samanpr/jalalicalendar/JalaliCalendar.java to a Painless script, then using that to generate the correct output from queries. You could also calculate & store the Jalali month in documents as they are ingested, then use that to bucket the data on queries.

It'll probably be easier to take the output from Elasticsearch and converting it in whatever is reading the output downstream. Adding the functionality to elasticsearch directly would unfortunately be a lot of work.

nevahid commented 1 year ago

I see, you are right about it. I will try that, besides i will figure out how is data saved on elasticsearch and how queries are passed, so that maybe a conversion is enough to achieve what we need.

thecoop commented 1 year ago

Great, hope those suggestions help