1

I have created a test index in elasticsearch with mapping for 2 date fields. Both fields have custom format as shown below.

{
  "test" : {
    "mappings" : {
      "_doc" : {
        "properties" : {
          "endTime" : {
            "type" : "date",
            "format" : "yyyy-MM-dd HH:mm:ss.SSS"
          },
          "startTime" : {
            "type" : "date",
            "format" : "yyyy-MM-dd HH:mm:ss.SSS"
          }
        }
      }
    }
  }
}

Data i have loaded for this sample test index looks like below.

PUT test/_doc
{
  "startTime" : "2019-02-26 00:00:00.000",
  "endTime" : "2019-02-27 00:00:00.000"
}

I am trying to query based on range but it doesnt return any result. Am i missing something? My query for range is as below.

GET test/_doc/search
{
  "query": {
    "bool": {
      "must": {
        "range": {
          "endTime": {
            "gte": "2019-02-25 00:00:00.000",
            "format" : "yyyy-MM-dd HH:mm:ss.SSS"
          }
        }
      }
    }
  }
}

1 Answer 1

1

You've got everything right... except the search endpoint, which is _search not search

GET test/_doc/_search
              ^
              |
           add this

Also note that you probably have created a new document whose id is search, you probably want to delete it using DELETE test/_doc/search.

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

2 Comments

Yes seems like that was the mistake. Thanks
Also note that for the benefit of others, you should ask a new question instead of modifying the original one to ask a new unrelated question...

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.