0

I have the following documents in elasticsearch, and I'd like to apply prefix query on logtime field, but nothing would return.

      {
    "_index" : "test",
    "_type" : "fluentd",
    "_id" : "6Cn38mMBMKvgU4HnnURh",
    "_score" : 1.0,
    "_source" : {
      "logtime" : "2018-06-11 03:08:02,117",
      "userid" : "",
      "payload" : "40",
      "qs" : "[['I have a dream, that everybody'], ['the'], ['steins']]"
    }
  }

the prefix query is

curl -X GET "localhost:9200/test/_search" -H 'Content-Type: application/json' -d'{ "query": {"prefix" : { "logtime" : "2018-06-11" }}}'

Could someone help? Thanks a lot.

2
  • Do you want to fetch All documents of date 2018-06-11. Commented Jun 13, 2018 at 4:36
  • @Richa yes, this is my requirement. Commented Jun 13, 2018 at 4:40

1 Answer 1

3

You can use Range Query in that case like

{
 "query": {
  "range": {
  "createdDate": {
    "gte":"2018-06-11",
    "lte": "2018-06-11",
    "format": "yyyy-MM-dd"
    }
   }
  }
 }

Hope it helps.

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.