2015-10-14 140 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你的問題。 –