es 分詞器(五)之elasticsearch-analysis-jieba 8.7.0

es 分詞器(五)之elasticsearch-analysis-jieba 8.7.0

今天咱們就來講一下es jieba 8.7.0 分詞器的實現,以及8.x其它版本的實現方式,如果想直接使用es 結巴8.x版本,請直接修改pom文件的elasticsearch.version版本號即可,然后打包安裝就行,不需要做太多的操作。

一、elasticsearch-jieba-plugin

最近更新的版本為8.4.1,最近更新的時間停留在2022年,從這之后便無人維護此開源項目
GitHub地址:??https://github.com/sing1ee/elasticsearch-jieba-plugin/tree/8.4.1??

二、elasticsearch-analysis-jieba

最近更新的版本為6.8.17,比上面的插件更慘,已經有三年無人維護了。
Github地址:??https://github.com/huaban/elasticsearch-analysis-jieba/tree/dependabot/maven/org.elasticsearch-elasticsearch-6.8.17??

三、決定換殼elasticsearch-jieba-plugin

當前我開發的項目采用的版本為8.7.0,目前在網上無法找到與之匹配的版本。
ik分詞器用戶比jieba分詞器用戶多,因為會對應的es版本不斷更新,目前ik分詞器的版本已經更新至8.12.2,2024年5月14日位置es的最新版本為8.14.x
2024年5月14日es最新版本為8.14.x

四、編譯elasticsearch-analysis-jieba分詞器

由于原有的插件【elasticsearch-analysis-jieba】已經很久沒有人使用,但我又感覺【elasticsearch-analysis-jieba】這個名稱比【elasticsearch-jieba-plugin】【https://github.com/sing1ee/elasticsearch-jieba-plugin/tree/8.4.1】這個好聽一點,所以我本地新開了一個【elasticsearch-analysis-jieba】項目,將這個【elasticsearch-jieba-plugin】這個項目的代碼復制到新建的項目中,因為這個【elasticsearch-jieba-plugin】使用的是gradle管理,我想使用的是maven倉庫,所以修改了一下。

image-20240515221232488

4.1 新增pom.xml文件

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"><name>elasticsearch-analysis-jieba</name><modelVersion>4.0.0</modelVersion><groupId>org.elasticsearch</groupId><artifactId>elasticsearch-analysis-jieba</artifactId><version>${elasticsearch.version}</version><packaging>jar</packaging><description>jieba Analyzer for Elasticsearch</description><inceptionYear>2011</inceptionYear><properties><elasticsearch.version>8.7.0</elasticsearch.version><maven.compiler.target>17</maven.compiler.target><elasticsearch.assembly.descriptor>${project.basedir}/src/main/assemblies/plugin.xml</elasticsearch.assembly.descriptor><elasticsearch.plugin.name>analysis-jieba</elasticsearch.plugin.name><elasticsearch.plugin.classname>org.elasticsearch.plugin.analysis.jieba.AnalysisJiebaPlugin</elasticsearch.plugin.classname><elasticsearch.plugin.jvm>true</elasticsearch.plugin.jvm><tests.rest.load_packaged>false</tests.rest.load_packaged><skip.unit.tests>true</skip.unit.tests></properties><licenses><license><name>The Apache Software License, Version 2.0</name><url>http://www.apache.org/licenses/LICENSE-2.0.txt</url><distribution>repo</distribution></license></licenses><developers><developer><name>INFINI Labs</name><email>hello@infini.ltd</email><organization>INFINI Labs</organization><organizationUrl>https://infinilabs.com</organizationUrl></developer></developers><parent><groupId>org.sonatype.oss</groupId><artifactId>oss-parent</artifactId><version>9</version></parent><distributionManagement><snapshotRepository><id>oss.sonatype.org</id><url>https://oss.sonatype.org/content/repositories/snapshots</url></snapshotRepository><repository><id>oss.sonatype.org</id><url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url></repository></distributionManagement><repositories><repository><id>oss.sonatype.org</id><name>OSS Sonatype</name><releases><enabled>true</enabled></releases><snapshots><enabled>true</enabled></snapshots><url>https://oss.sonatype.org/content/repositories/releases/</url></repository></repositories><dependencies><dependency><groupId>org.elasticsearch</groupId><artifactId>elasticsearch</artifactId><version>${elasticsearch.version}</version><scope>compile</scope></dependency><dependency><groupId>com.huaban</groupId><artifactId>jieba-analysis</artifactId><version>1.0.2</version></dependency><dependency><groupId>org.apache.logging.log4j</groupId><artifactId>log4j-api</artifactId><version>2.19.0</version></dependency><dependency><groupId>junit</groupId><artifactId>junit</artifactId><version>4.13.2</version><scope>test</scope></dependency></dependencies><build><plugins><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-compiler-plugin</artifactId><version>3.5.1</version><configuration><source>${maven.compiler.target}</source><target>${maven.compiler.target}</target></configuration></plugin><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-surefire-plugin</artifactId><version>2.11</version><configuration><includes><include>**/*Tests.java</include></includes></configuration></plugin><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-source-plugin</artifactId><version>2.1.2</version><executions><execution><id>attach-sources</id><goals><goal>jar</goal></goals></execution></executions></plugin><plugin><artifactId>maven-assembly-plugin</artifactId><configuration><appendAssemblyId>false</appendAssemblyId><outputDirectory>${project.build.directory}/releases/</outputDirectory><descriptors><descriptor>${basedir}/src/main/assemblies/plugin.xml</descriptor></descriptors><archive><manifest><mainClass>fully.qualified.MainClass</mainClass></manifest></archive></configuration><executions><execution><phase>package</phase><goals><goal>single</goal></goals></execution></executions></plugin></plugins></build><profiles><profile><id>disable-java8-doclint</id><activation><jdk>[1.8,)</jdk></activation><properties><additionalparam>-Xdoclint:none</additionalparam></properties></profile><profile><id>release</id><build><plugins><plugin><groupId>org.sonatype.plugins</groupId><artifactId>nexus-staging-maven-plugin</artifactId><version>1.6.3</version><extensions>true</extensions><configuration><serverId>oss</serverId><nexusUrl>https://oss.sonatype.org/</nexusUrl><autoReleaseAfterClose>true</autoReleaseAfterClose></configuration></plugin><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-release-plugin</artifactId><version>2.1</version><configuration><autoVersionSubmodules>true</autoVersionSubmodules><useReleaseProfile>false</useReleaseProfile><releaseProfiles>release</releaseProfiles><goals>deploy</goals></configuration></plugin><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-compiler-plugin</artifactId><version>3.5.1</version><configuration><source>${maven.compiler.target}</source><target>${maven.compiler.target}</target></configuration></plugin><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-gpg-plugin</artifactId><version>1.5</version><executions><execution><id>sign-artifacts</id><phase>verify</phase><goals><goal>sign</goal></goals></execution></executions></plugin><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-source-plugin</artifactId><version>2.2.1</version><executions><execution><id>attach-sources</id><goals><goal>jar-no-fork</goal></goals></execution></executions></plugin><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-javadoc-plugin</artifactId><version>2.9</version><executions><execution><id>attach-javadocs</id><goals><goal>jar</goal></goals></execution></executions></plugin></plugins></build></profile></profiles>
</project>

4.2 修改plugin-descriptor.properties文件

# Elasticsearch plugin descriptor file
# This file must exist as 'plugin-descriptor.properties' at
# the root directory of all plugins.
#
# A plugin can be 'site', 'jvm', or both.
#
### example site plugin for "foo":
#
# foo.zip <-- zip file for the plugin, with this structure:
#   _site/ <-- the contents that will be served
#   plugin-descriptor.properties <-- example contents below:
#
# site=true
# description=My cool plugin
# version=1.0
#
### example jvm plugin for "foo"
#
# foo.zip <-- zip file for the plugin, with this structure:
#   <arbitrary name1>.jar <-- classes, resources, dependencies
#   <arbitrary nameN>.jar <-- any number of jars
#   plugin-descriptor.properties <-- example contents below:
#
# jvm=true
# classname=foo.bar.BazPlugin
# description=My cool plugin
# version=2.0.0-rc1
# elasticsearch.version=2.0
# java.version=1.7
#
### mandatory elements for all plugins:
#
# 'description': simple summary of the plugin
description=${project.description}
#
# 'version': plugin's version
version=${project.version}
#
# 'name': the plugin name
name=${elasticsearch.plugin.name}
#
# 'classname': the name of the class to load, fully-qualified.
classname=${elasticsearch.plugin.classname}
#
# 'java.version' version of java the code is built against
# use the system property java.specification.version
# version string must be a sequence of nonnegative decimal integers
# separated by "."'s and may have leading zeros
java.version=${maven.compiler.target}
#
# 'elasticsearch.version' version of elasticsearch compiled against
# You will have to release a new version of the plugin for each new
# elasticsearch release. This version is checked when the plugin
# is loaded so Elasticsearch will refuse to start in the presence of
# plugins with the incorrect elasticsearch.version.
elasticsearch.version=${elasticsearch.version}

4.3 新增plugin-security.policy文件

grant {// needed because of the hot reload functionalitypermission java.net.SocketPermission "*", "connect,resolve";permission java.lang.RuntimePermission "setContextClassLoader";
};

4.4 構建插件

打包

image-20240515221635642

找到打包之后的zip包

image-20240515221711379

放到elasticsearch-8.7.0/plugin/analysis-jieba目錄下。

image-20240515221917297

現在,再手動重啟一下es就將elasticsearch-analysis-jieba分詞器安裝好啦。

五、測試jieba分詞器

在kibana中創建索引

PUT jieba_index
{"settings": {"analysis": {"analyzer": {"my_ana": {"tokenizer": "jieba_index","filter": ["lowercase"]}}}}
}

文本分詞器

PUT jieba_index/_analyze
{"analyzer" : "my_ana","text" : "黃河之水天上來"
}

返回結果

{"tokens": [{"token": "黃河","start_offset": 0,"end_offset": 2,"type": "word","position": 0},{"token": "黃河之水天上來","start_offset": 0,"end_offset": 7,"type": "word","position": 0},{"token": "之水","start_offset": 2,"end_offset": 4,"type": "word","position": 1},{"token": "天上","start_offset": 4,"end_offset": 6,"type": "word","position": 2},{"token": "上來","start_offset": 5,"end_offset": 7,"type": "word","position": 2}]
}

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/web/12937.shtml
繁體地址,請注明出處:http://hk.pswp.cn/web/12937.shtml
英文地址,請注明出處:http://en.pswp.cn/web/12937.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

再談畢業論文設計投機取巧之IVR自動語音服務系統設計(信息與通信工程專業A+其實不難)

目錄 舉個IVR例子格局打開&#xff0c;萬物皆能IVR - 把《民法典》搬上IVR IVR系統其實可鹽可甜。還能可圈可點。 戎馬一生&#xff0c;歸來依然IVR。 舉個IVR例子 以下是IVR系統的一個例子。 當您撥打電話進入IVR系統。 首先檢驗是否為工作時間。 如是&#xff0c;您將被送入…

基于51單片機的自動澆花器電路

一、系統概述 自動澆水灌溉系統設計方案&#xff0c;以AT89C51單片機為控制核心&#xff0c;采用模塊化的設計方法。 組成部分為&#xff1a;5V供電模塊、土壤濕度傳感器模塊、ADC0832模數轉換模塊、水泵控制模塊、按鍵輸入模塊、LCD顯示模塊和聲光報警模塊&#xff0c;結構如…

垃圾分類管理系統java項目

文章目錄 垃圾分類管理系統一、項目演示二、項目介紹三、系統部分功能截圖四、部分代碼展示五、底部獲取項目&#xff08;9.9&#xffe5;帶走&#xff09; 垃圾分類管理系統 一、項目演示 垃圾分類管理系統 二、項目介紹 系統角色&#xff1a;管理員、用戶 1、登錄、注冊功能…

機器人非線性系統反饋線性化與解耦

機器人非線性系統的反饋線性化和解耦是控制理論中的兩個重要概念&#xff0c;它們分別用于簡化系統分析和設計過程&#xff0c;提高控制系統的性能。 首先&#xff0c;反饋線性化是一種將非線性系統轉化為線性系統的技術。在機器人控制中&#xff0c;由于機器人本身是一個強耦…

?python使用selenium進行Web自動化測試?

什么是selenium Selenium 是 ThoughtWorks 提供的一個強大的基于瀏覽器的 Selenium 是一個用于 Web 應用程序測試的工具&#xff0c;測試直接自動運行在瀏覽器中&#xff0c;就像真正的用戶在手工操作一樣。支持的瀏覽器包括 IE、Chrome 和 Firefox 等。這個工具的主要功能包…

2024042001-計算機網絡 - 物理層

計算機網絡 - 物理層 計算機網絡 - 物理層 通信方式帶通調制 通信方式 根據信息在傳輸線上的傳送方向&#xff0c;分為以下三種通信方式&#xff1a; 單工通信&#xff1a;單向傳輸半雙工通信&#xff1a;雙向交替傳輸全雙工通信&#xff1a;雙向同時傳輸 帶通調制 模擬信號…

C++基礎——繼承(下)

一、繼承與靜態成員 基類定義了static 靜態成員&#xff0c;則整個繼承體系里面只有一個這樣的成員。無論派生出多少個子 類&#xff0c;都只有一個 static 成員實例 。 class person { public:person(const char* name "lisi"):_name(name){} public:string _name;…

那些年我與c++的叫板(一)--string類自實現

引子&#xff1a;我們學習了c中的string類&#xff0c;那我們能不能像以前數據結構一樣自己實現string類呢&#xff1f;以下是cplusplus下的string類&#xff0c;我們參考參考&#xff01; 廢話不多說&#xff0c;直接代碼實現&#xff1a;&#xff08;注意函數之間的復用&…

Nacos+GateWay 搭建微服務架構

文章目錄 1.當前項目架構分析1.請求多個模塊的方式1.請求renren-fast模塊開發環境生產環境 2.請求sunliving-commodity模塊1.使用環境變量資源路徑的方式2.開發環境 dev.env.js3.生產環境 prod.env.js 3.文件上傳請求 sunliving-service模塊1.請求后端接口&#xff08;開發環境…

當服務實例出現故障時,Nacos如何處理?

當服務實例出現故障時&#xff0c;Nacos的應對策略 在微服務架構日益盛行的今天&#xff0c;服務之間的穩定性與可靠性成為了我們架構師們不得不面對的重要課題。尤其是在面對服務實例出現故障時&#xff0c;如何確保整個系統的穩定運行&#xff0c;成為了我們首要考慮的問題。…

匯聚榮科技:拼多多上架商品后需要做頁面推廣嗎?

在電商平臺上&#xff0c;商品的曝光率和銷量往往成正比。那么&#xff0c;當您在拼多多上架了新品&#xff0c;是不是就意味著坐等訂單呢?答案顯然是否定的。商品一旦上架&#xff0c;接下來需要做的就是通過有效的頁面推廣來增加商品的可見度&#xff0c;吸引潛在買家的注意…

在亞馬遜上賣燈具需要什么認證,亞馬遜燈飾產品需要審核與認證嗎

LED燈具在亞馬遜美國站銷售&#xff0c;需要有UL認證或者UL報告、FCC&#xff0c;如果是帶消毒滅菌的燈&#xff0c;需要做EPA&#xff0c;歐洲站&#xff0c;日本站&#xff0c;認證只需要CE和ROHSR認證。 UL認證&#xff1a;本認證主要針對充電器、移動電源、手機電池、燈具…

Rust的NLL特性:讓生命周期管理更靈活

Rust的NLL特性&#xff1a;讓生命周期管理更靈活 Rust語言以其獨特的內存安全和并發性能受到開發者的青睞。而在Rust中&#xff0c;一個關鍵的概念就是“生命周期”。為了進一步優化生命周期的管理和借用檢查&#xff0c;Rust引入了NLL&#xff08;Non-Lexical Lifetime&#…

html基礎(全)

html簡介 目錄 什么是網頁 什么是 HTML 常用瀏覽器 WebE標準的構成 基本語法概述 第一個HTML頁面 文檔類型聲明標簽 lang 語言種類 字符集 標題標簽 段落和換行標簽 文本格式化標簽 div和span標簽 圖像標簽和路徑 超鏈接標簽 表格的主要作用 表頭單元格標簽 列…

純血鴻蒙APP實戰開發——Web獲取相機拍照圖片案例

介紹 本示例介紹如何在HTML頁面中拉起原生相機進行拍照&#xff0c;并獲取返回的圖片。 效果預覽圖 使用說明 點擊HTML頁面中的選擇文件按鈕&#xff0c;拉起原生相機進行拍照。完成拍照后&#xff0c;將圖片在HTML的img標簽中顯示。 實現思路 添加Web組件&#xff0c;設置…

【SpringBoot】SpringBoot整合jasypt進行重要數據加密

&#x1f4dd;個人主頁&#xff1a;哈__ 期待您的關注 目錄 &#x1f4d5;jasypt簡介 &#x1f525;SpringBoot使用jasypt &#x1f4c2;創建我需要的數據庫文件 &#x1f4d5;引入依賴 &#x1f513;配置數據庫文件&#xff08;先不進行加密&#xff09; &#x1f319;創…

Anaconda安裝-超詳細版(2024)

掃盲&#xff1a;先裝Python還是先裝anaconda? 安裝anaconda即可&#xff0c;不需要單獨裝python anaconda 是一個python的發行版&#xff0c;包括了python和很多常見的軟件庫, 和一個包管理器conda。 一、下載Anaconda 安裝包&#xff08;官網和國內鏡像資源&#xff09; …

【深度學習】SDXL中的Offset Noise,Diffusion with Offset Noise,帶偏移噪聲的擴散

https://www.crosslabs.org//blog/diffusion-with-offset-noise 帶有偏移噪聲的擴散 針對修改后的噪聲進行微調&#xff0c;使得穩定擴散能夠輕松生成非常暗或非常亮的圖像。 作者&#xff1a;尼古拉斯古藤伯格 | 2023年1月30日 馬里奧兄弟使用穩定擴散挖掘隧道。左圖顯示了未…

Springboot+Vue項目-基于Java+MySQL的高校專業實習管理系統(附源碼+演示視頻+LW)

大家好&#xff01;我是程序猿老A&#xff0c;感謝您閱讀本文&#xff0c;歡迎一鍵三連哦。 &#x1f49e;當前專欄&#xff1a;Java畢業設計 精彩專欄推薦&#x1f447;&#x1f3fb;&#x1f447;&#x1f3fb;&#x1f447;&#x1f3fb; &#x1f380; Python畢業設計 &…