2015-04-02 119 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