elasticsearch - Range query for a keyword or a date type field? -
i have field store insert time,such 2016-10-10 11:00:00.000
,i tried keyword
type , date
type,they meet range
requirements,such
{ "query": { "range" : { "time" : { "gte" : "2016-10-10 11:00:00.000", "lte" : "2016-10-10 12:00:00.000" } } } }
keyword
, date
type better?
in case, since you're storing dates, it's more appropriate use date
data type, indeed. internally, dates stored long
timestamps , range query run on them, have numerical range.
keyword
intended used string data. if store dates keyword, dates stored unanalyzed strings , range query run on them consider them lexical range.
if ever need create date_histogram
aggregation out of dates, keyword
type won't it. should prefer date
data type.
Comments
Post a Comment