Exact date search with formatter


(Narendra Nallabelli) #1

HI Team ,

date field stored in elastic eg : 2015-11-22T19:27:35.814+0000 (java.util.date with UTC TZ)

my input darte is 2015-11-22T00:00:00.000-05:00

i want to skip time stamp from input and compare the date filed in the elastic
search for exact date " 2015-11-22" . term or range filter are not working .. plz help..

Thanks,
Naren


(Yodog) #2

this is how i do it:

var DateFormatElastic = 'yyyy-MM-dd';
var QueryFrom         = $('#txtStartDate').val();
var QueryTo           = $('#txtEndDate').val();

"query": { "bool": {
    "must" : [
        { "match" : { "verb" : "expunge"} },
        { "range" : { "@timestamp" : { "from": QueryFrom, "to": QueryTo, "format": DateFormatElastic, "time_zone": "America/Sao_Paulo" } } },
    ],
}}

(system) #3