1

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
  • 1
    you should use gte, not lte Commented Sep 25, 2017 at 11:14

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.