https://github.com/bells/elasticsearch-analysis-dynamic-synonym
2.1更新源码里面的es版本,es版本之前的差异很大 更新的很快一定要更新es的版本
2.2修改配置里面的db连接信息
jdbc.url=jdbc:oracle:thin:@10.111.12.11:5555
jdbc.user=ddd
jdbc.password=ddd
jdbc.reload.synonym.sql=SELECT word FROM TEST.SYNONYM_WORD WHERE STATUS = 0
jdbc.lastModified.synonym.sql=SELECT MAX(UPDATE_TIME) AS last_modify_dt FROM TEST.SYNONYM_WORD
jdbc.driver=oracle.jdbc.driver.OracleDriver
maven打包上传到 es部署下有个目录/plugins/
重启es服务查看启动日志 是否有加载到你的插件,如果是多节点部署其他的节点也要加上,不然导致集群不健康,分片数据损坏等等
"settings" : {
"index" : {
"blocks" : {
"read_only_allow_delete" : "false"
},
"provided_name" : "test",
"max_result_window" : "1000000",
"creation_date" : "1624350571075",
"analysis" : {
"synonym_custom" : {
"type" : "dynamic_synonym",
"synonyms_path" : "fromDB"
}
},
"analyzer" : {
"test_ik" : {
"filter" : [
"lowercase",
"synonym_custom"
],
"char_filter" : [
"html_strip"
],
"tokenizer" : "ik_max_word"
},
"test_ik_search" : {
"filter" : [
"lowercase",
"synonym_custom"
],
"char_filter" : [
"html_strip"
],
"tokenizer" : "ik_smart"
}
}
}
}
}
定义为filter,然后两个分词器,一个是跑索引数据的时候用的,一个是搜索的时候用的,分词的细粒度不一样