Date_histogram with date range

I tried to use date histogram with specific range ,
{
"aggs": {
"group_by_created_ts": {
"range": {
"date_histogram": {
"field": "created_ts",
"interval": "day",
"format": "yyyy-MM-dd",
"ranges": [
{
"to": "2019-03-29"
},
{
"from": "2019-02-29"
}
]
}
}
}
}
}

it gives error
"type": "x_content_parse_exception",
"reason": "[5:13] [range] unknown field [date_histogram], parser not found"

try this:

{
          "query": {
            "range": {
              "snapTime": {
                "from": "2019-02-28",
                "to": "2019-03-29"
              }
            }
          },
          "aggs": {
            "group_by_created_ts": {
              "date_histogram": {
                "field": "created_ts",
                "interval": "day",
                "format": "yyyy-MM-dd"
              }
            }
          }
        }

but if date type is text then how we run this

Why do you use text type? Date_histogram is applied on numeric fields.

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