ElasticSearch对象过滤器无法正常工作

时间:2015-10-14 13:08:24

标签: elasticsearch

我尝试使用Jest创建映射和索引。 我插入一些数据后,我试图过滤查询,它不起作用。

我有一个像这样的对象映射:

http://localhost:9200/contacts?pretty=true
"contacts" : {
  ...
     "mappings" : {
        "contact" : {
            "properties" : {
              ...
              "user" : {
                 "properties" : {
                   "id" : {
                   "type" : "long"
                  },
                  "uuid" : {
                    "type" : "string"
                  }
               }
            }
        }
 }

数据:

{
  "_index" : "contacts",
  "_type" : "contact",
  "_id" : "131530ff-d125-47c1-8fae-f48f2def9037",
  "_version" : 1,
  "found" : true,
  "_source":{"id":"131530ff-d125-47c1-8fae-f48f2def9037","shared":false,"favourite":false,"user":{"id":1,"uuid":"AB353469"}}
}

我的查询:

http://localhost:9200/contacts/_search
{
  "query":{  
     "filtered":{  
         ...
         "filter":{
            "term" : { 
            "user.uuid" : "AB353469" }
          }
     }
  }
}

响应:

{
  "took": 14,
  "timed_out": false,
  "_shards": {
    "total": 5,
    "successful": 5,
    "failed": 0
  },
  "hits": {
     "total": 0,
     "max_score": null,
     "hits": []
  }
}

你能告诉我为什么它不起作用吗? 非常感谢你!

P.S: - Elasticsearch版本:1.7.2

1 个答案:

答案 0 :(得分:2)

更改initiatorUuid映射
              "initiatorUuid" : {
                "type" : "string"
              }

              "initiatorUuid" : {
                "type" : "string",
                "index": "not_analyzed"
              }

重新创建索引,重新索引文档并重试。