Elasticsearch polymerization in a polymerization date range DateRange

Range compared to the polymerization, date range is the range may be specified by time.

E.g:

{
    "aggs":{
        "range":{
            "date_range":{
                "field":"date",
                "format":"MM-yyy",
                "ranges":[
                    {"to":"now-10M/M"},
                    {"from":"now-10M/M"}
                ]
            }
        }
    }
}

Where to: now-10M / M said that in the past 10 months ago

from: now-10M / M said that from now to 10 months ago

The results obtained on the following:

{
    ...
    "aggregations":{
        "range":{
            "buckets":[
                {
                    "to":1.3437792E+12,
                    "to_as_string":"08-2012",
                    "doc_count":7
                },{
                    "from":1.3437792E+12,
                    "from_as_string":"08-2012",
                    "doc_count":2
                }
            ]
        }
    }
}

It also supports many other date of expression, can refer joda date representation.

Reproduced in: https: //my.oschina.net/u/204616/blog/545006

Guess you like

Origin blog.csdn.net/weixin_34357962/article/details/91990166