Reputation: 14417
So I would like to know what now-1y
is producing as a result. So is it:
now - 365days
now - 365.25days
2014-12-23T08:46:00
I've read this documentation but can't find any more information.
Upvotes: 2
Views: 127
Reputation: 179
To answer the general question asked above: use the validate API.
indexname/_validate/query?rewrite=true
{
"query": {
"range": {
"modifiedDate": {
"gte": "now-1y/y",
"lte": "now/y"
}
}
}
}
And you get:
{
"_shards": {
"total": 1,
"successful": 1,
"failed": 0
},
"valid": true,
"explanations": [
{
"index": "indexname",
"valid": true,
"explanation": "+modifiedDate:[1640995200000 TO 1704067199999] #FieldExistsQuery [field=_primary_term]"
}
]
}
This lets you see exactly what value is being used for a given query.
Upvotes: 0
Reputation: 374
After some testing it appears that the third proposition is correct (ie "now with the year part subtracted, so 2014-12-23T08:46:00"
If 2 was correct the following example should have return 2 results. example1
As 2012 is a leap year. The following example should return 0 result if 1 was correct. example2
Note: example only worked as expected when I wrote this answer, in order to make it work for you, you have to update the date field of the indexed document.
Upvotes: 1