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

Count api parses wrong date range query when using "now" #3625

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

When using the count API with date range queries that contain now (e.g. [* TO now-1d]), the parsed query contains a negative number that leads to count 0 being returned. The following curl reproduction shows the different result obtained using the search API and the count 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 using search api
curl -XGET localhost:9200/index1/_search -d '
{ 
    "query" : {
        "query_string": {
            "query": "date:[* TO now-1d]"
        }   
    }
}
'
#count 0 using count api
curl -XGET localhost:9200/index1/_count -d '
{ 
    "query_string": {
      "query": "date:[* TO now-1d]"
    }
}
'

@ghost ghost assigned javanna Sep 5, 2013

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

Added tests for count api
testDateRangeInQueryString awaits fix (#3625)

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

Added tests for count api
testDateRangeInQueryString awaits fix (#3625)

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

Set nowInMillis to search context created by the count api so that "N…
…OW" can be used within queries

Added nowInMillis to ShardCountRequest in a backwards compatible manner

Fixes elastic#3625

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

Set nowInMillis to search context created by the count api so that "N…
…OW" can be used within queries

Added nowInMillis to ShardCountRequest in a backwards compatible manner

Fixes #3625

@javanna javanna closed this in 06bfe05 Sep 20, 2013

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

Added tests for count api
testDateRangeInQueryString awaits fix (elastic#3625)

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

Set nowInMillis to search context created by the count api so that "N…
…OW" can be used within queries

Added nowInMillis to ShardCountRequest in a backwards compatible manner

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