1、上传zip包
到映射文件下/mnt/sdc/docker/elk/elasticsearch/plugins/analyzer-synonym
2、挂载映射文件docker-compose.yml添加
- /mnt/sdc/docker/elk/elasticsearch/plugins:/usr/share/elasticsearch/plugins
3、进入容器
docker exec -it (es的id) /bin/bash
4、解压文件
unzip elasticsearch-analysis-dynamic-synonym-7.14.2.zip
5、查看插件
GET _cat/plugins
6、设置setting
PUT syno_index_name
{
“settings”: {
“index”:{
“number_of_shards”: “1”,
“number_of_replicas”: “1”,
“max_result_window”: “200000”,
“analysis”: {
“analyzer”: {
“synonym”: {
“type”:“custom”,
“tokenizer”: “standard”,
“filter”: [“remote_syno_filter”,“lowercase”]
}
},
“filter”:{
“remote_syno_filter”:{
“type”:“dynamic_synonym”,
“synonyms_path”:同义词接口地址url
}
}
}
}
},
“mappings”: {
“properties”: {
“col_name”: {
“type”: “text”,
“analyzer”: “synonym”
}
}
}
}
7、同义词分析
GET /syno_index_name/_analyze
{
“text”: “小鹏”,(同义词)
“analyzer”: “synonym”
}
8、导入数据后查看同义词是否生效
GET syno_index_name/_search
{
“query”: {
“match”: {
“col_name”: “Sinopec”
}
}
}