Search code examples
elasticsearchhistogramopensearch

How to get Full Day name (in uppercase) through Elastic Search query?


I want the Day name of record_created_at here, as MONDAY, TUESDAY, ... Format

I tried with the below, i'm getting the only first 3 letters and that too in Title case,

{
    "date_histogram": {
        "calendar_interval": "day",
        "field": "record_created_at",
        "format": "E"
    }
}

How can i can get full day name in Upper case?


Solution

  • You can use below query and it will give you the full day names in aggregation. you can refer this document.

    {
        "date_histogram": {
            "calendar_interval": "day",
            "field": "record_created_at",
            "format": "EEEE"
        }
    }
    

    You can not change the capitalization and you can done once getting response from Elasticsearch. You can refer this answer as Elasticsearch internally use DateTimeFormatter for formatting.