1.es配置ansj插件
ansj插件的git地址:https://github.com/NLPchina/elasticsearch-analysis-ansj,下载下来后,maven 运行package(打包).得到的zip包解压出来,放在es安装目录中的plugins文件夹里面.其中conf文件夹里的ansj.cfg.yml可以配置远程动态获取词典.

2.ansj暴露的api整理

请求链接 描述
/_cat/ansj 执行分词
/_cat/ansj/config 显示全部配置
/_ansj/flush/config 刷新全部配置
/_ansj/flush/config/single 执行刷新配置
/_ansj/flush/dic 更新全部词典
/_ansj/flush/dic/single 执行更新词典
/_cat/ansj 执行分词
例子:/_cat/ansj?text=中国&type=index_ansj&dic=dic&stop=stop&ambiguity=ambiguity&synonyms=synonyms
其中text和type是必须传的:text为需要进行分词的语句,type是分词类型,支持如下
base_ansj, -- 基本分词
index_ansj, -- 索引分词,拆分的最细
query_ansj,-- 查询分词
dic_ansj, -- 用户自定义分词
nlp_ansj;-- 自然语言分词
网友评论