search - Elasticsearch. Range query for strings with dashes -
i'm using elasticsearch data have string-field date values, this:
"2016-01-25 18:40:18.933"
i'm trying use range filter getting values date date. example:
"query" : { "filtered" : { "query" : { "range" : { "createddate" : { "gte": "2015-11-01", "lte": "2016-01-25" } } } } } }
but results doesn't contain values "createddate": "2015-12-14 20:28:23.557"
if use "gte": "2015"
or "gte": "2014-12-31"
, values "createddate": "2015-12-14"
included in results.
what's wrong in query?
if want able run range
queries on dates, need map field date
field, otherwise won't work expect. in mapping shared, createddate
string
. need wipe index , create new 1 proper mapping createddate
field, this:
curl -xpost localhost:9200/documents -d '{ "mappings": { "order": { "properties": { "createddate": { "type": "date" } } } } }'
then can reindex data , range
query work expected.
Comments
Post a Comment