2015-10-14 71 views
1

我尝试使用Jest创建映射和索引。 插入一些数据后,我试图过滤查询,并没有奏效。ElasticSearch对象过滤器不工作

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

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": [] 
    } 
} 

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

PS: - Elasticsearch版本:1.7.2

回答

2

变化initiatorUuid映射从

   "initiatorUuid" : { 
       "type" : "string" 
       } 

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

重新创建索引,重新建立索引的文件,并尝试再次。

+0

它现在有效! 非常感谢@安德烈! 我无法赞成,因为我没有足够的声誉:太伤心了: –

+0

:-)不用担心。 Upvoted你的问题。 –