-
Notifications
You must be signed in to change notification settings - Fork 25.8k
BREAKING CHANGE - Range Query by Date Year returns no results #47473
Description
Elasticsearch version (bin/elasticsearch --version): 7.4.0
Plugins installed: ["mapper-size"]
JVM version (java -version): using official docker image.
OS version (uname -a if on a Unix-like system):using official docker image.
Description of the problem including expected versus actual behavior:
Date range queries that were working in 5.x latest are no longer when we upgraded to Elastic 7.x
Here are the exact scripts needed to create the sample for 5.x
PUT /test
{
"mappings" : {
"doc": {
"properties" : {
"mydate" : { "type" : "date" }
}
}
}
}
POST /test/doc/
{
"mydate": "2016-07-23T00:00:00"
}
GET /test/_search
POST /test/_search
{
"query": {
"bool": {
"filter": [
{
"bool": {
"must": [
{
"range": {
"mydate": {
"gte": "2015",
"lte": "2017"
}
}
}
]
}
}
]
}
}
}
# This seems to be a bug as well. specifying any value in GTE returns the document.
POST /test/_search
{
"query": {
"bool": {
"filter": [
{
"bool": {
"must": [
{
"range": {
"mydate": {
"gte": "201555",
"lte": "2019"
}
}
}
]
}
}
]
}
}
}
Here are the exact scripts needed to create the sample for 7.x
PUT /test
{
"mappings" : {
"properties" : {
"mydate" : { "type" : "date" }
}
}
}
POST /test/_doc/
{
"mydate": "2016-07-23T00:00:00"
}
GET /test/_search
POST /test/_search
{
"query": {
"bool": {
"filter": [
{
"bool": {
"must": [
{
"range": {
"mydate": {
"gte": "2015",
"lte": "2017"
}
}
}
]
}
}
]
}
}
}
The query returns no results on 7.x but returns results on 5.x. Also as shown in the query example above, it seems like you can put any numeric value in 5.x on the gte query and it will return results.
Changing the Elasticsearch 7.x query to include the full date format for lte returns results (along with invalid gte values)
POST /test/_search
{
"query": {
"bool": {
"filter": [
{
"bool": {
"must": [
{
"range": {
"mydate": {
"gte": "2015",
"lte": "2017-01-01"
}
}
}
]
}
}
]
}
}
}
or
POST /test/_search
{
"query": {
"bool": {
"filter": [
{
"bool": {
"must": [
{
"range": {
"mydate": {
"gte": "2015-01-01",
"lte": "2017-01-01"
}
}
}
]
}
}
]
}
}
}
or
POST /test/_search
{
"query": {
"bool": {
"filter": [
{
"bool": {
"must": [
{
"range": {
"mydate": {
"gte": "2015555",
"lte": "2017-01-01"
}
}
}
]
}
}
]
}
}
}
I started digging into the formats and all breaking changes and all looks ok... Interesting enough I noticed the following docs changed a bit and no longer talk as much about date range queries (between 6.x and 7.x