为同义词插件支持MySQL连接获取远程词库。
该源码修改自:
- bells / elasticsearch-analysis-dynamic-synonym
- lxc-123 / elasticsearch-analysis-dynamic-synonym-6.5.0
保留了最初的基本功能,可以参考https://github.com/bells/elasticsearch-analysis-dynamic-synonym 文档。
对于MySQL连接部分,用法如下:
{
"settings" :{
"index" : {
"number_of_shards": "1",
"number_of_replicas": "0",
"analysis" : {
"analyzer" : {
"synonym" : {
"tokenizer" : "whitespace",
"filter" : ["remote_synonym_database"]
}
},
"filter" : {
"remote_synonym_database" : {
"type" : "dynamic_synonym",
"db_url" : "jdbc:mysql://127.0.0.1:3306/database",
"db_table": "table",
"db_user": "root",
"db_pass": "root",
"dic_type": "test",
"interval": 30
}
}
}
}
},
"mappings": {
"doc": {
"properties":{
"field1": {
"type": "text",
"analyzer": "synonym"
}
}
}
}
}
db_url
: 指定数据库链接db_table
: 指定使用的表db_user
,db_pass
: 数据库连接认证dic_type
: 可以分类型加载不同的词