简体   繁体   English

ElasticSearch 日期范围查询返回所有值

[英]ElasticSearch Date Range query returning all values

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.我想选择大于或等于 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弹性搜索版本:5.0.2

lte means lessthan or equal to the date. lte表示小于或等于日期。 So you get all dates before 2017/06/10 and the date itself.所以你会得到 2017/06/10 之前的所有日期和日期本身。 You have to use gte which means greater-than or equal.你必须使用gte这意味着大于或等于。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM