【问题标题】:Term filter for boolean types does not return any results布尔类型的术语过滤器不返回任何结果
【发布时间】:2014-03-12 23:31:42
【问题描述】:

我有一些具有以下索引的数据(这只是相关部分):

{
  "content": {
    "mappings" : {
      "content": {
        "properties": {
          "published" : {
            "type": "boolean"
          }
        }
      }
    }
  }
}

当我使用

查询所有内容时
GET content/content/_search
{}

我用published: true 找回了很多文档,但是当我使用术语过滤器进行查询时:

GET content/content/_search
{
  "filter": {
    "term": {
      "published": true
    }
  }
}

我没有得到任何结果。我的术语过滤器出了什么问题?

【问题讨论】:

  • 我还应该注意,映射中还有"type": "string"的其他属性在以相同方式查询时返回结果。

标签: elasticsearch filtering


【解决方案1】:

奇怪,它在 ES1.0 上对我有用:

我为这样的文档编制了索引:

PUT /twitter/tweet/1
{
    "bool":true
}

这是我的映射:

GET /twitter/tweet/_mapping
{
   "twitter": {
      "mappings": {
         "tweet": {
            "properties": {
               "bool": {
                  "type": "boolean"
               }
            }
         }
      }
   }
}

我可以这样搜索:

GET twitter/tweet/_search
{
  "filter": {
    "term": {
      "bool": true
    }
  }
}

我得到了这些结果:

{
   "took": 3,
   "timed_out": false,
   "_shards": {
      "total": 1,
      "successful": 1,
      "failed": 0
   },
   "hits": {
      "total": 1,
      "max_score": 1,
      "hits": [
         {
            "_index": "twitter",
            "_type": "tweet",
            "_id": "1",
            "_score": 1,
            "_source": {
               "bool": true
            }
         }
      ]
   }
}

【讨论】:

    【解决方案2】:

    这个问题与查询无关......似乎我的自定义河流导入数据不正确。

    【讨论】:

      猜你喜欢
      • 2018-09-22
      • 2015-11-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-02-23
      • 2013-11-24
      • 2015-09-01
      相关资源
      最近更新 更多