Incorrect result with date range query in elasticsearch

Hi All,

I have been struggling with this query;

    "range": {
    "opened_at": {
   "gt": "2017-02-02 00:00:00",
   "time_zone":"-05:00" 

        }
        }

but I get the result for:

"opened_at": "2017-01-06 15:40:04",

the mapping for the field is:

"opened_at": {
"type": "date",
"format": "yyyy-MM-DD HH:mm:ss"
},

Also, we have nested field with the same name and format under a parent_field called "abc"
"abc"
{
"type": "text",
"properties{
"opened_at": {
"type": "date",
"format": "yyyy-MM-DD HH:mm:ss"
}
}
},

Please let me know where improvement is required.

Best,
Divya Bhardwaj

I'm not sure it's related to your problem but the first thing that stands out for me is

"format": "yyyy-MM-DD HH:mm:ss"


DD is day of year not day of month
. Not sure how that influences parsing given there is conflicting evidence (day of year would already suggest a month which might be at odds with the MM data provided)

thanks Mark, that really helped

1 Like

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