2015-09-16 73 views
2

注:彈性搜索,查詢字符串查詢,綴搜索不帶連字符工作

' is the quotation mark for the better reading of each string value. 
(star) is * 

字符串值,如「卡爾斯魯厄Durlach」,「卡爾斯魯厄」,「卡爾斯魯厄)Südstadt」和「慕尼黑」存儲在彈性搜索中。

我的問題:

像 '(星)汝河-DURL(星)' 應與存儲的字符串 '卡爾斯魯厄Durlach' 相匹配的搜索字符串。

我的想法是:

GET _search 
{ 
    "query": { 
     "query_string": { 
      "query": "*ruhe-Durl*" 
     }  
    } 
} 

=>沒有結果

如果字符串 ' 「卡爾斯魯厄Durlach」' 被搜索:

GET _search 
{ 
    "query": { 
     "query_string": { 
      "query": "\"Karlsruhe-Durlach\"" 
     }  
    } 
} 

=> '卡爾斯魯厄Durlach'將是結果。

如果字符串 '(星) 「rlsruhe-Durlac」(星號)' 被搜索:

GET _search 
{ 
    "query": { 
     "query_string": { 
      "query": "*\"rlsruhe-Durlac\"*", 
      "default_field" : "city" 
     }  
    } 
} 

> '卡爾斯魯厄-Durlach', '卡爾斯魯厄', '卡爾斯魯厄)Südstadt' 和「慕尼黑'會是結果。

如果字符串 '(星)urlac(星)' 被搜索:

GET _search 
{ 
    "query": { 
     "query_string": { 
      "query": "*urlac*" 
     }  
    } 
} 

> '卡爾斯魯厄-Durlach' 將結果。

該指數創建如下:

{ 
    "settings":{ 
    "index":{ 
     "analysis":{ 
      "analyzer":{ 
       "german":{ 
       "tokenizer":"keyword", 
       "filter":"standard" 
       } 
      } 
     } 
    } 
    }, 
"mappings":{ 
    "organization":{ 
     "properties":{ 
      "id":{ 
       "analyzer": "german", 
       "index": "not_analyzed", 
       "type":"string" 
      } 
     } 
    } 
    } 
} 

你能給我一個建議,如何與連字符綴搜索字符串應該寫?像'(星)ruhe-Durl(星)'這樣的中綴搜索字符串只能與'Karlsruhe-Durlach'匹配。中綴搜索字符串處或索引創建處是否有錯誤?

感謝您的支持。

回答