Elasticsearch中ik添加同义词
参考http://elasticsearch.cn/?/question/29
配置synonym.txt
在config目录下analysis,在analysis目录里新建synonym.txt文件,内容如下1
2beijing,北京,帝都
上海,魔都
配置elasticsearch.yml
在elasticsearch.yml里添加1
2
3
4
5
6
7
8
9
10
11
12
13
14
15index:
analysis:
filter:
my_synonym:
type: synonym
synonyms_path: analysis/synonym.txt
analyzer:
ik_smart_syno:
type: custom
tokenizer: ik_smart
filter: [my_synonym]
ik_max_word_syno:
type: custom
tokenizer: ik_max_word
filter: [my_synonym]
测试
新建索引curl -XPUT 'localhost:9200/test?pretty'
,之后执行http://localhost:9200/test/_analyze?analyzer=ik_max_word_syno&text=上海外滩