Description
Elasticsearch version (bin/elasticsearch --version
): 6.8.5 and 7.5.0
Plugins installed: default from docker image docker.elastic.co/elasticsearch/elasticsearch:6.8.5
and docker.elastic.co/elasticsearch/elasticsearch:7.5.0
JVM version (java -version
):
OpenJDK Runtime Environment AdoptOpenJDK (build 13.0.1+9)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 13.0.1+9, mixed mode, sharing)
OS version (uname -a
if on a Unix-like system):
Linux dd0d4200f531 4.15.0-70-generic #79-Ubuntu SMP Tue Nov 12 10:36:11 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
Description of the problem including expected versus actual behavior:
When using date_range
type in combination with range
query, range lte
seems to round down. I would expect this to round up as it does with fields of date type.
Steps to reproduce:
Please include a minimal but complete recreation of the problem, including
(e.g.) index creation, mappings, settings, query etc. The easier you make for
us to reproduce it, the more likely that somebody will take the time to look at it.
- Create index with the following mapping:
curl -X PUT "localhost:9200/mytest?pretty" -H 'Content-Type: application/json' -d'
{
"mappings": {
"properties": {
"foo": {
"type": "date"
},
"bar": {
"type": "date_range"
}
}
}
}
'
- Index the following document:
curl -X POST "localhost:9200/mytest/_doc/?pretty" -H 'Content-Type: application/json' -d'
{
"foo": "2019-12-09T12:00:00.000Z",
"bar": {
"gte": "2019-12-09T12:00:00.000Z",
"lte": "2019-12-09T13:00:00.000Z"
}
}
'
- Search using range query:
curl -X GET "localhost:9200/mytest/_search?pretty" -H 'Content-Type: application/json' -d'
{
"query":{
"range":{
"bar": {
"gte":"2019-12-09||/d",
"lte":"2019-12-09||/d"
}
}
}
}
'
Yields no hits. I would expect gte
to round to start of day, and lte
to round to end of day, but it appears lte
rounds to start of day. It works as expected when changing range query to use foo
field. It also works correctly if I change lte
to 2019-12-10||/d
or 2019-12-09T23:59:59
.