No exact match for RANGE query for a specific time No exact match for RANGE query for a specific time elasticsearch elasticsearch

No exact match for RANGE query for a specific time


Elasticsearch uses Joda-Time for parsing dates. And your problem is that Joda-Time only stores date/time values down to the millisecond.

From the docs:

The library internally uses a millisecond instant which is identical to the JDK and similar to other common time representations. This makes interoperability easy, and Joda-Time comes with out-of-the-box JDK interoperability.

This means that the last 3 digits of the seconds are not taken into account when parsing the date.

2017-11-30T13:23:23.063612+11:00
2017-11-30T13:23:23.063657+11:00
2017-11-30T13:23:23.063722+11:00

Are all interpreted as:
2017-11-30T13:23:23.063+11:00

And the corresponding epoch time is 1512008603063 for all these values.

You can see this too by adding explain to the query like this:

{    "query": {        "range" : {            "time" : {                "gte": "2017-11-30T13:23:23.063657+11:00",                "lte": "2017-11-30T13:23:23.063657+11:00"            }        }    },     "explain": true}

That is basically the reason all those documents match your query.