2015-04-02 122 views
0

我將索引title_o作爲非索引字段。查詢以獲得精確搜索不返回結果。當title_o匹配時,我需要查找文檔是test1。請幫忙。彈性搜索中的完全匹配搜索不起作用

Indexed following documents: 
curl -XPUT 'http://localhost:9200/test/test10/1' -d ' 
{ 
    "doi":"1234", 
    "title":"this is test1", 
    "title_o":"this is test1" 

}' 



curl -XPUT 'http://localhost:9200/test/test10/3' -d ' 
{ 
    "doi":"1234", 
    "title":"this is test3", 
    "title_o":"this is test3" 

}' 

Search: 
curl -XGET 'http://localhost:9200/test/test10/_search?pretty=true' -d ' 
{ 
    "query" : { 
     "filtered" : { 
      "filter" : { 
       "term" : { 
        "title_o" : "this is test1" 
       } 
      } 
     } 
    } 
}' 
+0

你可以發佈映射嗎? – Tom 2015-04-02 23:51:12

回答

0

如果您將標題字段映射爲「index」:「no」,這會告知ElasticSearch使此字段不可用於搜索。在你的情況下,如果你計劃使用這個字段進行精確的字符串匹配,請確保你的字段映射爲「index」:「not_analyzed」。

+0

我有以下映射「title」:{ 「type」:「multi_field」, 「fields」:{「type」:「string」,「index」:「analysed」,「store 「:真正}, 」title_o「:{」 類型 「:」 串」, 「指數」: 「not_analyzed」} }, 「存儲」: 「是的」, 「提升」:10 \t \t \t} , – Malini 2015-04-03 16:57:49

+0

確切searchcurl -XGET的 'http://本地主機:9200 /測試/ test10/_search漂亮=真' -D' { 「查詢」:{ 「過濾」:{ 「過濾器」:{ 「術語「:{ 」標題.title_o「:」This is test6「 } } } } }'is not working – Malini 2015-04-03 17:01:38