Time range query without "TO"

Hi,

Since Elasticsearch 5.2 to 5.4.0 (I haven't checked other versions, but these were installed on my server) I was able to use the following statement in my queries:

timestamp: [now-2d now]

It worked just fine. When I've upgraded to 5.5.0 it stopped working and now throws an exception (https://pastebin.com/6XxifrMW) saying I must put "TO" between "now-2d" and "now".

I've checked release notes for 5.5 and failed to find anything that could explain the change in behavior.

If it was an intentional change, I'll have no problems with changing my queries, but I just want to confirm that it wasn't a side effect of changes in something else.

I agree that this is looking like a regression to me.

I checked it on 5.2.2 and 5.5.1 and your report is exact.
Would you like to open an issue?

If it was done on purpose I think it needs to be documented at least.

Thanks for the reply!

Since you confirm it, then yes, I'll open an issue.

upd: https://github.com/elastic/elasticsearch/issues/25905

1 Like

Okey, it was a bug that it worked without "TO" :slight_smile:

This leniency was not intended and of course never documented :wink:
This is just a side effect of a sloppy rule in the parser and should be considered as bug.
The strict parsing has been introduced in:
[LUCENE-7821] Classic, flexible, and Solr's standard/"lucene" query parsers: range queries should require " TO ", and accept TO as range endpoints - ASF JIRA
The query_string uses a strict parser that throws exceptions when the syntax is not valid. I don't think we should handle non-documented syntax forever just because they worked in some versions.
Sorry but you'll have to fix your query in es > 5.5.

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