Git Product home page Git Product logo

elastic_ansj_plug's Introduction

##前言 这是一个elasticsearch的中文分词插件,基于ansj,感谢作者阿键,感谢群内热心的朋友。 并宣传一下我们的群QQ211682609

##插件安装

  • 第一步,你要有一个elasticsearch的服务器(废话)

  • 第二步,把代码clone到本地

  • 第三步,mvn clean assembly:assembly(破maven。今天把我整崩溃了。发誓以后能不用maven发布项目就不用了。受不了这个破玩意)

  • 第四步,进入$Project_Home/target/ 目录,

  • 第五步,拷贝$Project_Home/target/elasticsearch-analysis-ansj-0.1-jar-with-dependencies.jar 到es的lib目录中

  • 第六步,将$Project_Home/target/config目录合并到es中的config目录

  • 第七步,配置分词插件,将下面配置粘贴到,es下config/elasticsearch.yml 文件末尾。

################################## ANSJ PLUG CONFIG ################################
index.analysis.analyzer.default.type : org.ansj.elasticsearch.index.analysis.AnsjIndexAnalyzerProvider
#是否提取词干默认为false
ansj_pstemming : false
#用户自定义辞典。如果是目录的话辞典文件必须以dic结尾
ansj_user_path : library/default.dic
#歧义排错
ansj_ambiguity : library/ambiguity.dic
#停用词辞典路径
stop_path : library/stop.dic

以上配置中redis并不是必需的,user_path可以是一个目录。 如果使用redis功能,请确认一下,在user_path下有ext.dic这个文件

##使用 在mapping中,加入analyzer设置,请注意,分词和索引使用不一样的分词器

"byName": {
  "type": "string",
  "index_analyzer": "index_ansj",
  "search_analyzer": "query_ansj"
}

可以使用分词器测试接口还看到效果:

curl -XGET http://host:9200/_analyze?analyzer=query_ansj&text=视康 隐形眼镜

然后通过redis发布一个新词看看

redis-cli
publish ansj_term c:视康

是不是分词发生了变化

redis-cli
publish ansj_term d:视康

又回来了

#结束 就写这么多吧,有啥问题,QQ找我

elastic_ansj_plug's People

Contributors

ansjsun avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

guansj

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.