Using a date range query with include_lower set to false is not working as expected in ES8. In ES7 a doc with a date of 1969-12-31 with date range query set to 1969-12-31 as the lower bound and include_lower=false would return no results, as expected. In ES8, the same query returns the doc. On the ES8 migration doc I don't see a change like this mentioned. Is this a bug? If so, should I report it to the github repo?
#create index
curl -X PUT localhost:9200/myidx
#create mapping
curl -H "Content-type: application/json" -X PUT localhost:9200/myidx/_mapping -d'{"dynamic":"strict","properties":{"id":{"type":"keyword"},"mydate":{"type":"date","format":"yyyy-MM-ddXXX"}}}'
#Add doc with value 1969-12-31
curl -H "Content-type: application/json" -X POST localhost:9200/myidx/_doc/1 -d'{"id":"1","mydate":"1969-12-31Z"}'
#Query for date range from 1969-12-31 to 2030-10-31 and EXCLUDE the lower and upper endpoints. EXPECT: no result since we are excluding 1969-12-31. The value "-86400000" is 1969-12-31
curl -H "Content-type: application/json" -X POST localhost:9200/myidx/_search -d'{"from":0,"size":5,"query":{"bool":{"must":[{"bool":{"filter":[{"bool":{"must":[{"range":{"mydate":{"from":-86400000,"to":null,"include_lower":false,"include_upper":true,"format":"epoch_millis","boost":1.0}}},{"range":{"mydate":{"from":null,"to":1919635200000,"include_lower":true,"include_upper":false,"format":"epoch_millis","boost":1.0}}}],"adjust_pure_negative":true,"boost":1.0}}],"adjust_pure_negative":true,"boost":1.0}}],"adjust_pure_negative":true,"boost":1.0}},"track_total_hits":2147483647}'
Using ES7 via docker run -e cluster.name=docker-cluster -e cluster.initial_master_nodes=myes -e node.name=myes docker.elastic.co/elasticsearch/elasticsearch:7.17.10
I get 0 results:
{"took":29,"timed_out":false,"_shards":{"total":1,"successful":1,"skipped":0,"failed":0},"hits":{"total":{"value":0,"relation":"eq"},"max_score":null,"hits":[]}}
Using ES8 via docker run -e xpack.security.enabled=false -e cluster.name=docker-cluster -e cluster.initial_master_nodes=myes -e node.name=myes docker.elastic.co/elasticsearch/elasticsearch:8.13.4
I get 1 result:
{"took":5,"timed_out":false,"_shards":{"total":1,"successful":1,"skipped":0,"failed":0},"hits":{"total":{"value":1,"relation":"eq"},"max_score":0.0,"hits":[{"_index":"myidx","_id":"1","_score":0.0,"_source":{"id":"1","mydate":"1969-12-31Z"}}]}}