Elasticsearch:搜索布尔字段

Der*_*ero 6 elasticsearch

我在 Elasticsearch 集群中有几个文档,其中有一个isInFight包含布尔值的字段。映射已正确设置(已仔细检查过)为布尔值。

当我运行搜索时:

 curl -XGET localhost:9200/default/_search --data '{"query": {"term": {"isInFight": true}}}'
Run Code Online (Sandbox Code Playgroud)

I get documents returned with the field being true and false. Changing the value in my search query to false no documents are returned at all.

To me this looks like the term query checked for the field being present or not rather then for it's value. Everything I found on the internet suggests that this query is the way to go though.

Am I missing something here? Is there a known bug regarding this?

The Elasticsearch in question is version 5.5.2 with lucene version 6.6.0 on an ubuntu 16.04 server.

dee*_*wan 5

在我本地的elasticsearch中尝试这个并没有发现问题

POST test_index/doc
{
  "id": 1,
  "isInFight": false
}

POST test_index/doc
{
  "id": 2,
  "isInFight": true
}

POST test_index/doc
{
  "id": 3,
  "isInFight": true
}

GET test_index/doc/_search
{
  "query": {
    "term": { "isInFight": false }
  }
}
Run Code Online (Sandbox Code Playgroud)

并得到了这个结果

{
  "took": 4,
  "timed_out": false,
  "_shards": {
    "total": 5,
    "successful": 5,
    "failed": 0
  },
  "hits": {
    "total": 1,
    "max_score": 0.2876821,
    "hits": [
      {
        "_index": "test_index",
        "_type": "doc",
        "_id": "AWU2Dxm7GR2l1TPuyKhN",
        "_score": 0.2876821,
        "_source": {
          "id": 1,
          "isInFight": false
        }
      }
    ]
  }
}
Run Code Online (Sandbox Code Playgroud)