Elasticsearch前缀查询在日期上不起作用

时间:2018-06-13 04:27:01

标签: elasticsearch

我在elasticsearch中有以下文档,我想在logtime字段上应用前缀查询,但不会返回任何内容。

      {
    "_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']]"
    }
  }

前缀查询是

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

有人可以帮忙吗?非常感谢。

1 个答案:

答案 0 :(得分:3)

在这种情况下,您可以使用Range Query,例如

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

希望它有所帮助。

相关问题