2017-07-03 92 views
1

我有提供炭過濾器自定義分析:Elasticsearch跳過符號@

"char_filter": { 
    "hash_repl": { 
     "pattern": "(^[^\\#@].+)", 
     "type": "pattern_replace", 
     "preserve_original": "false", 
     "replacement": "$1 #$1 @$1" 
     } 
    } 

當我送測試儀POST請求,我在等待的行爲,如:

a => a #a @a 
#a => #a 
@a => @a 

問題是彈性不會在響應中呈現「@」符號,通常我會得到

a => a #a a 
#a => #a 
@a => a 
+0

嘗試通常的事情:1)在@之前添加''\\'''2)嘗試複製'@'。 –

回答

0

那麼,解決方案很簡單。我的自定義分析器也包含幾個字符過濾器和令牌過濾器問題通過添加自定義映射來解決:

"char_filter": { 
    "custom": { 
     "type": "mapping", 
     "mappings": [ 
      "#=>|#" 
     ] 
     } 
}, 
"filter": { 
    "custom": { 
     "type": "word_delimiter", 
     "type_table": [ 
      "# => ALPHA", 
      "@ => ALPHA" 
     ], 
     "split_on_numerics": "false" 
    } 
}