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
}
]
}

Elasticsearch:Smart Chinese Analysis plugin的更多相关文章

  1. Elasticsearch:Pinyin 分词器

    Elastic的Medcl提供了一种搜索Pinyin搜索的方法.拼音搜索在很多的应用场景中都有被用到.比如在百度搜索中,我们使用拼音就可以出现汉字: 对于我们中国人来说,拼音搜索也是非常直接的.那么在 ...

  2. Elasticsearch:IK中文分词器

    Elasticsearch内置的分词器对中文不友好,只会一个字一个字的分,无法形成词语,比如: POST /_analyze { "text": "我爱北京天安门&quo ...

  3. ElasticSearch:分析器

    ElasticSearch入门 第七篇:分析器 这是ElasticSearch 2.4 版本系列的第七篇: ElasticSearch入门 第一篇:Windows下安装ElasticSearch El ...

  4. Elasticsearch:如何对PDF文件进行搜索

    Elasticsearch 通常用于字符串,数字,日期等数据类型的检索,但是在 HCM.ERP 和电子商务等应用程序中经常存在对办公文档进行搜索的需求.今天的这篇文章中我们来讲一下如何实现 PDF.D ...

  5. Elasticsearch:定制分词器(analyzer)及相关性

    转载自:https://elasticstack.blog.csdn.net/article/details/114278163 在许多的情况下,我们使用现有的分词器已经足够满足我们许多的业务需求,但 ...

  6. Elasticsearch:如何实现对 emoji 表情符号进行搜索

    转摘自:https://elasticstack.blog.csdn.net/article/details/114261636 Elasticsearch 是一个应用非常广泛的搜索引擎.它可以对文字 ...

  7. DBA应用技巧:如何升级InnoDB Plugin

    DBA应用技巧:如何升级InnoDB Plugin 2011-03-23 10:09 康凯 ITPUB 字号:T | T 本文中,我们将向读者详细介绍如何升级动态InnoDB Plugin和升级静态编 ...

  8. Elasticsearch:运用search_after来进行深度分页

    在上一篇文章 "Elasticsearch:运用scroll接口对大量数据实现更好的分页",我们讲述了如何运用scroll接口来对大量数据来进行有效地分页.在那篇文章中,我们讲述了 ...

  9. Elasticsearch:Index生命周期管理入门

    如果您要处理时间序列数据,则不想将所有内容连续转储到单个索引中. 取而代之的是,您可以定期将数据滚动到新索引,以防止数据过大而又缓慢又昂贵. 随着索引的老化和查询频率的降低,您可能会将其转移到价格较低 ...

随机推荐

  1. 开启apache2的ssl访问功能

    Ubuntu 20.04 1. Apache2默认安装的时候,ssl模块是不启用的.开启命令: $ sudo apt install apache2 #安装$ sudo a2enmod ssl #开启 ...

  2. JavaScript基本知识点——带你逐步解开JS的神秘面纱

    JavaScript基本知识点--带你逐步解开JS的神秘面纱 在我们前面的文章中已经深入学了HTML和CSS,在网页设计中我们已经有能力完成一个美观的网页框架 但仅仅是网页框架不足以展现出网页的魅力, ...

  3. testNG框架,使用@BeforeClass标注的代码,执行失败不抛出异常,只提示test ignore的解决方法

    郁闷了好久的一个问题,排错调试的时候是真滴麻烦... Google一圈,发现是testNG的Bug,升级testNG>=6.9.5,就能解决.

  4. N皇后的位运算有感

    N皇后很明显是一个NP-Hard问题,如果n足够大的话,在有限较短的时间内是很难得出答案的,但是注意到N皇后(笔者认为这类问题称为棋盘问题更为贴切),在n*n棋盘之上,每个点有且只有两种状态,这与电脑 ...

  5. 从零开始实现lmax-Disruptor队列(六)Disruptor 解决伪共享、消费者优雅停止实现原理解析

    MyDisruptor V6版本介绍 在v5版本的MyDisruptor实现DSL风格的API后.按照计划,v6版本的MyDisruptor作为最后一个版本,需要对MyDisruptor进行最终的一些 ...

  6. 什么是双网口以太网IO模块

    MXXXE系列远程IO模块工业级设计,适用于工业物联网和自动化控制系统,MxxxE工业以太网远程 I/O 配备 2 个mac层数据交换芯片的以太网端口,允许数据通过可扩展的菊花链以太网远程 I/O 阵 ...

  7. 钡铼BL102分布式IO系统如何应用于锂电池行业

    近年来,全球新能源汽车的蓬勃发展促进了锂电池行业的发展.随着锂电池标准化程度的提高,电池和模块规格的标准化是未来的发展趋势,也促进了自动化模块生产线的发展. 锂电池模块生产线通过涂胶-电池堆叠-组装- ...

  8. cmd命令行工具

    在windows下进行python开发,需要经常使用cmd命令行工具.打开命令行工具有很多种方法,最简单的就是win键+R键弹出运行窗口,然后输入cmd, 就会打开下面这样的窗口. 不同版本,可能配色 ...

  9. LuoguAT2827 LIS (LIS)

    裸题 #include <iostream> #include <cstdio> #include <cstring> #include <algorithm ...

  10. Dynamic CRM一对多关系的数据删除时设置自动删除关联的数据

    在业务实体中主子表非常常见,然后子表可能有会有自己的子表或者多对多关系,在删除的业务场景下,删除主数据,剩余的子数据就成了脏数据, 之前的做法是,监听主表的删除事件,然后在插件中找到其下的子表数据然后 ...