Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validate query api parses wrong date range query when using "now" #3629

Closed
javanna opened this Issue Sep 5, 2013 · 0 comments

Comments

Projects
None yet
1 participant
@javanna
Copy link
Member

javanna commented Sep 5, 2013

Same problem as #3625 and #3626, but with the validate query api.
When using the validate query API with date range queries that contain now (e.g. [* TO now-1d]), the parsed query contains a negative number that leads to a valid query anyway, but the explain shows that something went wrong while parsing the date range. The following curl reproduction shows the different result obtained using the search API and the validate query API.

curl -XPUT localhost:9200/index1/type1/1 -d '{
  "date": "2013-09-03T15:07:47.000Z"
}
'

curl -XPOST localhost:9200/index1/_refresh

#one hit gets returned (id 1) using search api
curl -XGET localhost:9200/index1/_search -d '
{ 
    "query" : {
        "query_string": {
            "query": "date:[* TO now-1d]"
        }   
    }
}
'
#validate query api returns a weird query with a negative time from epoch (`date:[* TO -86400000]`")
curl -XGET localhost:9200/index1/type1/_validate/query?explain -d '
{ 
    "query_string": {
      "query": "date:[* TO now-1d]"
    }
}
'

@ghost ghost assigned javanna Sep 5, 2013

javanna added a commit to javanna/elasticsearch that referenced this issue Sep 17, 2013

Set nowInMillis to search context created by the validate query api s…
…o that "NOW" can be used within queries

Added nowInMillis to ShardValidateQueryRequest in a backwards compatible manner

Fixes elastic#3629

javanna added a commit that referenced this issue Sep 20, 2013

Set nowInMillis to search context created by the validate query api s…
…o that "NOW" can be used within queries

Added nowInMillis to ShardValidateQueryRequest in a backwards compatible manner

Fixes #3629

@javanna javanna closed this in 0d38955 Sep 20, 2013

mute pushed a commit to mute/elasticsearch that referenced this issue Jul 29, 2015

Set nowInMillis to search context created by the validate query api s…
…o that "NOW" can be used within queries

Added nowInMillis to ShardValidateQueryRequest in a backwards compatible manner

Fixes elastic#3629
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.