Query date changes on elasticsearch 2.0

Hi, I am upgrading a cluster from elasticsearch 1.7 to 2.0 and I have noticed that a specific query is not behaving the same way on the different versions.

I am using the following script to test:


base_url="http://localhost:9201"

curl "${base_url}"
echo ""
echo "Removing index"
curl -X DELETE "$base_url/my_index"
echo ""

echo "Creating index and mapping"
curl -X POST "${base_url}/my_index" -d '
{
"settings": { "number_of_shars": "1", "number_of_replicas": "1" },
"mappings": {
"user": {
"properties": {
"name": { "type": "string" },
"created_at": {"type": "date", format: "date_optional_time" }
}
}
}
}
'
echo ""
echo "Add document"
curl -X PUT "${base_url}/my_index/user/1?refresh=true" -d '
{
"name": "Jonh Doe",
"created_at": "2017-02-05T12:30:45.123Z"
}
'
echo ""
echo "Query"

curl -X POST "${base_url}/my_index/user/_search?search_type=count" -d '
{
"query": {
"range": {
"created_at": {
"gte": "2017-01-01",
"lte": "2017-02-05"
}
}
}
}
'
echo ""

Results with elasticsearch 2.0.2

{
"name" : "Windshear",
"cluster_name" : "elasticsearch",
"version" : {
"number" : "2.0.2",
"build_hash" : "6abf5d8e5b37c2735d8e2f110f9743c453f71e92",
"build_timestamp" : "2015-12-16T12:49:58Z",
"build_snapshot" : false,
"lucene_version" : "5.2.1"
},
"tagline" : "You Know, for Search"
}

Removing index
{"acknowledged":true}
Creating index and mapping
{"acknowledged":true}
Add document
{"_index":"my_index","_type":"user","_id":"1","_version":1,"_shards":{"total":2,"successful":1,"failed":0},"created":true}
Query
{"took":3,"timed_out":false,"_shards":{"total":5,"successful":4,"failed":0},"hits":{"total":0,"max_score":0.0,"hits":[]}}

Results with elasticsearch 1.7.5

{
"status" : 200,
"name" : "Dr. John Grey",
"cluster_name" : "elasticsearch",
"version" : {
"number" : "1.7.6",
"build_hash" : "c730b59357f8ebc555286794dcd90b3411f517c9",
"build_timestamp" : "2016-11-18T15:21:16Z",
"build_snapshot" : false,
"lucene_version" : "4.10.4"
},
"tagline" : "You Know, for Search"
}

Removing index
{"acknowledged":true}
Creating index and mapping
{"acknowledged":true}
Add document
{"_index":"my_index","_type":"user","_id":"1","_version":1,"created":true}
Query
{"took":4,"timed_out":false,"_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":1,"max_score":0.0,"hits":[]}}


Elasticsearch 1.7 returns 1 and 2.0 returns 0.

I could not find exactly which change is responsible for this on the Breaking Changes document. I've noticed that the default date format has changed, but I expect the query to behave the same when specifying the same format.

Does anybody know why ES 2.0 behaves like this for this query?

Thanks,
Alisson

Hi @alissonsales,

this bug has been fixed in Elasticsearch 2.4.2.

Daniel

Thanks for the reply @danielmitterdorfer. I ended up opening an issue on Github about this https://github.com/elastic/elasticsearch/issues/23393 and confirmed it was fixed on 2.4.

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