Smart Chinese Analysis插件将Lucene的Smart Chinese分析模块集成到Elasticsearch中,用于分析中文或中英文混合文本。 支持的分析器在大型训练语料库上使用基于隐马尔可夫(Markov)模型的概率知识来查找简体中文文本的最佳分词。 它使用的策略是首先将输入文本分解为句子,然后对句子进行切分以获得单词。 该插件提供了一个称为smartcn分析器的分析器,以及一个称为smartcn_tokenizer的标记器。 请注意,两者均不能使用任何参数进行配置。

要将smartcn Analysis插件安装在Elasticsearch Docker容器中,请使用以下屏幕截图中显示的命令。 然后,我们重新启动容器以使插件生效:

./bin/elasticsearch-plugin install analysis-smartcn

在Elasticsearch的安装目录运行上面的命令。显示的结果如下:

    $ ./bin/elasticsearch-plugin install analysis-smartcn
-> Downloading analysis-smartcn from elastic
[=================================================] 100%
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.bouncycastle.jcajce.provider.drbg.DRBG (file:/Users/liuxg/elastic/elasticsearch-7.3.0/lib/tools/plugin-cli/bcprov-jdk15on-1.61.jar) to constructor sun.security.provider.Sun()
WARNING: Please consider reporting this to the maintainers of org.bouncycastle.jcajce.provider.drbg.DRBG
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
-> Installed analysis-smartcn
(base) localhost:elasticsearch-7.3.0 liuxg$ ./bin/elasticsearch-plugin list
analysis-icu
analysis-ik
analysis-smartcn
pinyin

上面显示我们已经成功地把analysis-smartcn安装成功了。针对docker的安装,我们可以通过如下的命令来进入到docker里,再进行安装:

    $ docker exec -it es01 /bin/bash
[root@ec4d19f59a7d elasticsearch]# ls
LICENSE.txt README.textile config jdk logs plugins
NOTICE.txt bin data lib modules
[root@ec4d19f59a7d elasticsearch]#

在这里es01是docker中的Elasticsearch实例。具体安装请参阅我的文章“Elastic:用Docker部署Elastic栈”。

注意:在我们安装好smartcn分析器后,我们必须重新启动Elasticsearch使它开始起作用。

实例

在下面,我们在Kibana中用一个实例来展示这个用法:

    POST _analyze
{
"text": "股市,投资,稳,赚,不,赔,必修课,如何,做,好,仓,位,管理,和,情绪,管理",
"analyzer": "smartcn"
}

显示结果:

    {
"tokens" : [
{
"token" : "股市",
"start_offset" : 0,
"end_offset" : 2,
"type" : "word",
"position" : 0
},
{
"token" : "投资",
"start_offset" : 3,
"end_offset" : 5,
"type" : "word",
"position" : 2
},
{
"token" : "稳",
"start_offset" : 6,
"end_offset" : 7,
"type" : "word",
"position" : 4
},
{
"token" : "赚",
"start_offset" : 8,
"end_offset" : 9,
"type" : "word",
"position" : 6
},
{
"token" : "不",
"start_offset" : 10,
"end_offset" : 11,
"type" : "word",
"position" : 8
},
{
"token" : "赔",
"start_offset" : 12,
"end_offset" : 13,
"type" : "word",
"position" : 10
},
{
"token" : "必修课",
"start_offset" : 14,
"end_offset" : 17,
"type" : "word",
"position" : 12
},
{
"token" : "如何",
"start_offset" : 18,
"end_offset" : 20,
"type" : "word",
"position" : 14
},
{
"token" : "做",
"start_offset" : 21,
"end_offset" : 22,
"type" : "word",
"position" : 16
},
{
"token" : "好",
"start_offset" : 23,
"end_offset" : 24,
"type" : "word",
"position" : 18
},
{
"token" : "仓",
"start_offset" : 25,
"end_offset" : 26,
"type" : "word",
"position" : 20
},
{
"token" : "位",
"start_offset" : 27,
"end_offset" : 28,
"type" : "word",
"position" : 22
},
{
"token" : "管理",
"start_offset" : 29,
"end_offset" : 31,
"type" : "word",
"position" : 24
},
{
"token" : "和",
"start_offset" : 32,
"end_offset" : 33,
"type" : "word",
"position" : 26
},
{
"token" : "情绪",
"start_offset" : 34,
"end_offset" : 36,
"type" : "word",
"position" : 28
},
{
"token" : "管理",
"start_offset" : 37,
"end_offset" : 39,
"type" : "word",
"position" : 30
}
]
}

最新文章

  1. Qt 程序访问 sqlite 权限错误
  2. Android 开机启动
  3. 【好用的小技巧】win8兼容、网页不让复制
  4. FastLoad错误 — SELECT Failed. 2652
  5. Cinema 4D R16安装教程
  6. 【推荐】JavaScript的那些书
  7. apache_fileupload实现文件上传_上传多个文件
  8. 快速美眉(FastMM)使用手记
  9. 通过JSP+servlet实现文件上传功能
  10. 2-SAT 问题与解法小结
  11. 监控报I/O问题,怎么办?
  12. eclipse中如何复制用点分隔的全类名
  13. 居于U2000手机管理光猫,小区运营商FTTH光猫注册神器,MA5680T手机管理,自动添加光猫
  14. JacobMathType
  15. 日常英语---六、Maplestory Illium
  16. TCP可靠传输:校验和,重传控制,序号标识,滑动窗口、确认应答
  17. Tomcat学习总结(15)—— Tomcat优化时的参数分析
  18. centos6.4安装 jupyter-notebook
  19. HDU - 5961 传递 想法,bfs
  20. C/C++ -- Gui编程 -- Qt库的使用 -- 纯代码实现信号槽

热门文章

  1. 文件的下载,HttpMessageConverter原理
  2. 在 Windows 上使用压缩文件 安装 MySQL
  3. Solution -「树状数组」 题目集合
  4. Centos7安装最新docker
  5. Hippo4J v1.3.1 发布,增加 Netty 监控上报、SpringCloud Hystrix 线程池监控等特性
  6. 吐泡泡_via牛客网
  7. AtCoder Beginner Contest 248 E - K-colinear Line // 计算几何
  8. 20220727-Java中多态总结
  9. 20170622日行一记之PHP函数
  10. 智慧文旅IOC大数据可视化建设方案