3
問題是任何帶有助推符的字符序列「^(插入符號)」不返回任何搜索結果。elastic搜索沒有用於產生特殊字符'^(插入符號)'
但按照下面的彈性搜索文檔
-
- & & || ! (){} [] ^「〜*:?。\字符可以與\符號轉義
有一個要求做在彈性搜索使用的n-gram分析裝置包含搜索
下面是示例用例的映射結構和
{
"settings": {
"index": {
"analysis": {
"analyzer": {
"nGram_analyzer": {
"filter": [
"lowercase",
"asciifolding"
],
"type": "custom",
"tokenizer": "ngram_tokenizer"
},
"whitespace_analyzer": {
"filter": [
"lowercase",
"asciifolding"
],
"type": "custom",
"tokenizer": "whitespace"
}
},
"tokenizer": {
"ngram_tokenizer": {
"token_chars": [
"letter",
"digit",
"punctuation",
"symbol"
],
"min_gram": "2",
"type": "nGram",
"max_gram": "20"
}
}
}
}
},
"mappings": {
"employee": {
"properties": {
"employeeName": {
"type": "string",
"analyzer": "nGram_analyzer",
"search_analyzer": "whitespace_analyzer"
}
}
}
}
}
有一個僱員姓名像下面有特殊字符包括 XYZ%^ & *
還用於樣品查詢包含搜索如下
GET
{
"query": {
"bool": {
"must": [
{
"match": {
"employeeName": {
"query": "xyz%^",
"type": "boolean",
"operator": "or"
}
}
}
]
}
}
}
即使我們試圖逃跑的「查詢」:「XYZ%\ ^」它的錯誤了。所以不能搜索任何字符包含搜索有「^(脫字符號)」
任何幫助,非常感謝。
感謝您的回覆@keety。 – user1876040