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

Explain api parses wrong date range query when using "now" #3626

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

Comments

Projects
None yet
1 participant
@javanna
Copy link
Member

commented Sep 5, 2013

Same problem as #3625, but with the explain api.
When using the explain API with date range queries that contain now (e.g. [* TO now-1d]), the parsed query contains a negative number that leads to a no match being returned. The following curl reproduction shows the different result obtained using the search API and the explain 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]"
        }   
    }
}
'
#explain api says the document doesn't match
curl -XGET localhost:9200/index1/type1/1/_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 explain api so that …
…"NOW" can be used within queries

Added nowInMillis to ExplainRequest in a backwards compatible manner

Fixes elastic#3626

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

Set nowInMillis to search context created by the explain api so that …
…"NOW" can be used within queries

Added nowInMillis to ExplainRequest in a backwards compatible manner

Fixes #3626

@javanna javanna closed this in 52e9e75 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 explain api so that …
…"NOW" can be used within queries

Added nowInMillis to ExplainRequest in a backwards compatible manner

Fixes elastic#3626
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.