Min_bucket date format does not work


(Gabor Toth) #1

Hi,

I am trying to format of a result of a min_bucket. (I want to get the minimum of maximum date by datasource, which is working well.)

GET my-index/_search
{
  "size": 0,
  
  "aggs": {
    "source": {
      "terms": {
        "field": "datasource",
        "size": 10
      },
      "aggs": {
        
        "maxdate": {
          
          "max": {
            "field": "my-timestamp",
            "format": "yyyy-MM-dd"
          }
        }
      }
      
    }
    ,
    
    "min_datez": {
      
      "min_bucket": {

        "buckets_path": "source>maxdate",
        "format": "date_time"
      }
    }
  }
}

Result:

...
"min_datez": {
      "value": 1533074400000,
      "value_as_string": "date_time1533074400000",
      "keys": [
        "some-key-1"
      ]
    }

I think formatting of "value_as_string" is wrong. How should I do date formatting in this case?