I'm learning Elasticsearch and have an issue with date range queries. My queries compare only days, not the whole dates. Here's a short example:
DELETE test
PUT /test
{
"mappings": {
"properties": {
"date" : {
"type": "date",
"format": "dd MM YYYY"
}
}
}
}
POST /_bulk
{"index" : {"_index": "test"}}
{"date": "01 01 2001"}
POST /test/_search
{
"query": {
"range": {
"date": {
"lt": "01 01 2016",
"gt": "01 01 2000"
}
}
}
}
POST /test/_search
{
"query": {
"range": {
"date": {
"lte": "01 01 2000",
"gte": "01 01 2016"
}
}
}
}
From my understanding the first search query should return the document - the date 2001 is < 2016 and > 2000. The second query should return nothing because 2001 is not <= 2000 and >=2016. But it works completely opposite.
Could you please point me what I'm missing?