🍉 Meet Flexmonster Pivot Table & Charts 2.9.Check out all hot features!
Get Free Trial

How to use a date or year/month with elasticsearch

abons asked on May 16, 2019

I want to add a year/month column like i could with json. But I get the following issues:
1. Date-type field is shown as string.
2. Year / month (numeric) fields has random ordering
3. Month (label) field didn’t test, but probably need ordering

1 answer

Tanya Gryshko Tanya Gryshko Flexmonster May 16, 2019

Hello, Abons,

Thank you for writing to us.

To modify dates representation in Elasticsearch we suggest configuring the mapping object: https://www.flexmonster.com/doc/configuring-the-mapping/.

Please pay attention to an interval property which is used to set intervals. One more important property is a format. For example, if you have a field named date, here is how to set an interval to 1 month and specify a format:

mapping: {
  "date": {
    "interval": "1M",
    "format": "MM/yyyy"

This doc specifies different interval options: https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-datehistogram-aggregation.html#_setting_intervals.
Hope it helps.


Please login or Register to Submit Answer