1
votes

I have created an index using below mapping.

Index Mapping:

{
  "mappings": {
    "document": {
        "properties": {
            "doc_date": {
          "type": "date" ,
          "format": "yyyy/MM/dd"
        }
      }
    }
  }
}

I indexed two records. Like below.

Records:

{
"doc_date": "2017/06/10",
"Record":"A"
}
{
"doc_date": "2017/05/10",
"Record":"D"
}

I wanted to select documents which are greater than or equal to date 2017/06/10.

Query:

{
    "query": {
        "range" : {
            "doc_date" : {
                "lte": "2017/06/10",
                "format": "yyyy/MM/dd"
            }
        }
    }
}

But the above query returned all the document in the index.

ElasticSearch version:5.0.2

1
you should use gte, not ltePraneeth

1 Answers

1
votes

lte means lessthan or equal to the date. So you get all dates before 2017/06/10 and the date itself. You have to use gte which means greater-than or equal.