Range query not working with format


(Steven Ensslen) #1

Hi all, I think that I've come across a defect.

I have an index with a date field, start_datetime

This more restrictive query returns data
GET /_search
{
"query": {
"range" : {
"start_datetime" : {
"gte": "10-05-2018",
"lte": "12-05-2018",
"format": "dd-mm-yyyy"
}
}
}
}

While this query, which asks for a superset of the previous query, returns nothing:
GET /_search
{
"query": {
"range" : {
"start_datetime" : {
"gte": "10",
"lte": "12",
"format": "dd"
}
}
}
}

I get a respoonse for May 10 to 12 of this year, but no data for the 10th to 12th of all months in all year.

Is this behaviour documented or should I open an issue?

Steven


(Alexander Reelsen) #2

The format, needs to expand to a specific date in order to be able to execute a range query.

if you need to filter by specific days of the month, the best strategy would be to extract that day into it's own field day_of_month, which as a short, and then do a simple range query against that.

--Alex


(Steven Ensslen) #3

Thanks Alex,

I've opened issue 30634 for the documentation. Please comment on that issue with (a link to?) the information that should be in the documentation.

Steven


(system) #4

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.