1

类型映射

{
  "pois-en": {
    "mappings": {
      "poi": {
        "properties": {
           "address": {
              "type": "string",
              "analyzer": "portuguese"
           },
           "city": {
              "type": "integer"
           },
           (...)
           "type": {
              "type": "integer"
           }
        }
      }
    }
  }
}

全部查询:

GET pois-en/_search
{
  "query":{
    "match_all":{}
  },
  "fields": ["city"]
}

返回:

"hits": [
     {
        "_index": "pois-en",
        "_type": "pois_poi",
        "_id": "491",
        "_score": 1,
        "fields": {
           "city": [
              91
           ]
        }
     },
     (...)

但是当我使用以下过滤器过滤时:

GET pois-en/_search
{
    "query" : {
        "filtered" : { 
            "query" : {
                "match_all" : {} 
            },
            "filter" : {
                "term" : { 
                    "city" : 91
                }
            }
        }
    }
}

它一无所获!

我无法弄清楚我做错了什么。对于 Django 和 Elasticsearch 通信,我是 Elasticutils ( https://github.com/mozilla/elasticutils ),但我现在使用 Sense 来进行这些查询。

提前致谢

4

1 回答 1

1

poi您的帖子 (和)中的类型名称不一致pois_poi- 返回的文档与您的映射不匹配。

于 2015-01-02T12:44:20.673 回答