Reputation: 107
I want to search for documents falls on a given date range but the range query doesn't return any result.
Field mapping:
TestDate
type "text"
fields
keyword
type "keyword"
ignore_above 256
I have tried this "range": {"TestDate": {"gte": "2015-01-01","lte":"2015-02-01"}}
I want all the documents satisfying the above condition.
Upvotes: 1
Views: 981
Reputation: 217514
You need to map the field as a date
instead, otherwise it won't work being mapped as text
{
...
"TestDate": {
"type": "date"
}
...
}
Only then your range
query will work:
{
"query": {
"range": {
"TestDate": {
"gte": "2015-01-01",
"lte":"2015-02-01"
}
}
}
}
Upvotes: 1