How to set week start day in elastic Aggregation

I want to set Sunday as the first of the week....

request

{
   "size":0,
   "query":{
      "bool":{
      	         "filter":[
            {
               "range":{
                  "@timestamp":{
                     "from":1601478000000,
                     "to":1607698799998,
                     "include_lower":true,
                     "include_upper":true
                  }
               }
            }
         ]
      }
   },
      "aggregations":{
      "by_date":{
         "date_histogram":{
            "field":"@timestamp",
            "interval":"1w",
            "format":"yyyy-MM-d-W",
            "time_zone": "Asia/Seoul",
            "min_doc_count":0,
            	"offset": "-1d",
            "extended_bounds":{
               "min":1601478000000,
               "max":1607698799998
            }
         }
      }
   }
}

response

"aggregations": {
        "by_date": {
            "buckets": [
                {
                    "key_as_string": "2020-09-27-4",
                    "key": 1601132400000,
                    "doc_count": 0
                },
                {
                    "key_as_string": "2020-10-4-1",
                    "key": 1601737200000,
                    "doc_count": 0
                },
                {
                    "key_as_string": "2020-10-11-2",
                    "key": 1602342000000,
                    "doc_count": 0
                },
                {
                    "key_as_string": "2020-10-18-3",
                    "key": 1602946800000,
                    "doc_count": 0
                },
                {
                    "key_as_string": "2020-10-25-4",
                    "key": 1603551600000,
                    "doc_count": 123
                },
                {
                    "key_as_string": "2020-11-1-0",
                    "key": 1604156400000,
                    "doc_count": 168
                },
                {
                    "key_as_string": "2020-11-8-1",
                    "key": 1604761200000,
                    "doc_count": 143
                },
                {
                    "key_as_string": "2020-11-15-2",
                    "key": 1605366000000,
                    "doc_count": 149
                },
                {
                    "key_as_string": "2020-11-22-3",
                    "key": 1605970800000,
                    "doc_count": 168
                },
                {
                    "key_as_string": "2020-11-29-4",
                    "key": 1606575600000,
                    "doc_count": 167
                },
                {
                    "key_as_string": "2020-12-6-1",
                    "key": 1607180400000,
                    "doc_count": 42
                }
            ]
        }
  • key_as_String : year-month-day-weekOfMonth

However, if you create the query as above, you will not be able to view it from the 1st as in October and December.
Is there a solution?

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.