{"id":22551247,"url":"https://github.com/sing1ee/elasticsearch-jieba-plugin","last_synced_at":"2026-01-23T07:41:26.048Z","repository":{"id":46342061,"uuid":"79224626","full_name":"sing1ee/elasticsearch-jieba-plugin","owner":"sing1ee","description":"jieba analysis plugin for elasticsearch","archived":false,"fork":false,"pushed_at":"2025-11-28T05:49:44.000Z","size":1505,"stargazers_count":535,"open_issues_count":0,"forks_count":153,"subscribers_count":22,"default_branch":"master","last_synced_at":"2025-11-30T16:02:34.643Z","etag":null,"topics":["dict","elasticsearch","elasticsearch-jieba-plugin","jieba","stopwords"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sing1ee.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2017-01-17T12:17:48.000Z","updated_at":"2025-11-28T06:29:45.000Z","dependencies_parsed_at":"2023-01-23T12:01:20.120Z","dependency_job_id":null,"html_url":"https://github.com/sing1ee/elasticsearch-jieba-plugin","commit_stats":null,"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"purl":"pkg:github/sing1ee/elasticsearch-jieba-plugin","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sing1ee%2Felasticsearch-jieba-plugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sing1ee%2Felasticsearch-jieba-plugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sing1ee%2Felasticsearch-jieba-plugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sing1ee%2Felasticsearch-jieba-plugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sing1ee","download_url":"https://codeload.github.com/sing1ee/elasticsearch-jieba-plugin/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sing1ee%2Felasticsearch-jieba-plugin/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28683996,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-23T05:48:07.525Z","status":"ssl_error","status_checked_at":"2026-01-23T05:48:07.129Z","response_time":59,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dict","elasticsearch","elasticsearch-jieba-plugin","jieba","stopwords"],"created_at":"2024-12-07T17:11:40.281Z","updated_at":"2026-01-23T07:41:26.040Z","avatar_url":"https://github.com/sing1ee.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# elasticsearch-jieba-plugin\n\nJieba 中文分词 Elasticsearch 插件\n\n## 更新日志\n\n### 20251128\n- 更新 ES 版本到 8.11.1\n- 更新 Java 版本到 17\n- 更新 jieba-analysis 依赖\n\n### 20221201\n- 新增 `7.17.x` 分支，支持 ES `7.17.0`\n- 新增 `8.4.1` 分支，支持 ES `8.4.1`\n\n---\n\n## 特点\n\n- 支持动态添加字典，不重启 ES\n- 简单修改即可适配不同版本的 ES\n\n## 快速开始\n\n### 环境要求\n\n| 组件 | 版本 |\n|------|------|\n| Gradle | 7.6 |\n| Java | 17+ (需与目标 ES 版本兼容) |\n| Elasticsearch | 8.11.1 (当前默认) |\n\n\u003e 参考 [ES 和 JDK 版本对应关系](https://www.elastic.co/cn/support/matrix#matrix_jvm)\n\n### 克隆项目\n\n```shell\ngit clone https://github.com/sing1ee/elasticsearch-jieba-plugin.git --recursive\ncd elasticsearch-jieba-plugin\n```\n\n### 构建打包\n\n```shell\n./gradlew clean pz\n```\n\n构建成功后，插件包位于：`build/distributions/elasticsearch-jieba-plugin-{version}.zip`\n\n### 安装到 Elasticsearch\n\n```shell\n# 复制到 ES 插件目录\ncp build/distributions/elasticsearch-jieba-plugin-1.0.0.zip ${ES_HOME}/plugins/\n\n# 解压\ncd ${ES_HOME}/plugins/\nunzip elasticsearch-jieba-plugin-1.0.0.zip\nrm elasticsearch-jieba-plugin-1.0.0.zip\n\n# 启动 ES\ncd ${ES_HOME}\n./bin/elasticsearch\n```\n### 测试分词\n```shell\n# 测试 jieba_search 分词器\ncurl -X POST \"localhost:9200/_analyze\" -H 'Content-Type: application/json' -d'\n{\n  \"analyzer\": \"jieba_search\",\n  \"text\": \"中华人民共和国国歌\"\n}\n'\n\n# 测试 jieba_index 分词器\ncurl -X POST \"localhost:9200/_analyze\" -H 'Content-Type: application/json' -d'\n{\n  \"analyzer\": \"jieba_index\",\n  \"text\": \"中华人民共和国国歌\"\n}\n'\n```\n---\n\n## 适配不同 ES 版本（完整教程）\n\n如果需要适配其他版本的 Elasticsearch，按以下步骤操作：\n\n### 第一步：确定版本信息\n\n根据目标 ES 版本，查阅 [ES 和 JDK 版本对应关系](https://www.elastic.co/cn/support/matrix#matrix_jvm)，确定需要的 Java 版本。\n\n例如：\n| ES 版本 | 推荐 Java 版本 |\n|---------|----------------|\n| 8.x     | 17, 21         |\n| 7.17.x  | 11, 17         |\n| 7.x     | 11             |\n\n### 第二步：修改 `build.gradle`\n\n修改以下三处：\n\n```groovy\n// 1. 插件版本（可选）\nversion = '1.0.0'\n\n// 2. Java 版本\nsourceCompatibility = \"17\"  // 改为你的 Java 版本\ntargetCompatibility = \"17\"  // 改为你的 Java 版本\n\n// 3. ES 依赖版本\ndependencies {\n    implementation 'org.elasticsearch:elasticsearch:8.11.1'  // 改为目标 ES 版本\n}\n```\n\n### 第三步：修改 `src/main/resources/plugin-descriptor.properties`\n\n```properties\n# 插件版本\nversion=1.0.0\n\n# Java 版本\njava.version=17\n\n# ES 版本（必须与 build.gradle 中一致）\nelasticsearch.version=8.11.1\n```\n\n### 第四步：确认 Java 环境\n\n```shell\njava -version\n```\n\n确保当前 Java 版本与配置一致。\n\n### 第五步：构建\n\n```shell\n./gradlew clean pz\n```\n\n### 第六步：验证\n\n构建成功后，检查生成的 zip 包：\n\n```shell\nls -la build/distributions/\n```\n\n---\n\n## 常见问题\n\n### Gradle Wrapper 缺失\n\n如果遇到 `ClassNotFoundException: org.gradle.wrapper.GradleWrapperMain`，执行：\n\n```shell\n# 如果已安装 Gradle\ngradle wrapper --gradle-version 7.6\n\n# 或手动下载\ncurl -L -o gradle/wrapper/gradle-wrapper.jar \\\n  https://github.com/gradle/gradle/raw/v7.6.0/gradle/wrapper/gradle-wrapper.jar\n```\n\n### Java 版本不匹配\n\n如果遇到 `错误: 无效的源发行版`，检查：\n1. 系统 Java 版本：`java -version`\n2. `build.gradle` 中的 `sourceCompatibility`\n3. `plugin-descriptor.properties` 中的 `java.version`\n\n确保三者一致。\n\n---\n\n## 相关文档\n\n- [支持动态添加字典，ES不需要重启](update_dict_online.md)\n- [jieba_index 和 jieba_search 的应用](about_jieba_index_jieba_search.md)\n- [简单修改适配不同版本 ES](custom_plugin_version.md)\n\n---\n\n## 版本对应\n\n| 分支      | tag        | elasticsearch版本 | Release Link                                                                                  |\n| ---       | ---        | ---               | ---                                                                                           |\n| master    | -          | v8.11.1           | 从源码构建                                                                                     |\n| 7.7.0     | tag v7.7.1 | v7.7.0            | Download: [v7.7.0](https://github.com/sing1ee/elasticsearch-jieba-plugin/releases/tag/v7.7.1) |\n| 7.4.2     | tag v7.4.2 | v7.4.2            | Download: [v7.4.2](https://github.com/sing1ee/elasticsearch-jieba-plugin/releases/tag/v7.4.2) |\n| 7.3.0     | tag v7.3.0 | v7.3.0            | Download: [v7.3.0](https://github.com/sing1ee/elasticsearch-jieba-plugin/releases/tag/v7.3.0) |\n| 7.0.0     | tag v7.0.0 | v7.0.0            | Download: [v7.0.0](https://github.com/sing1ee/elasticsearch-jieba-plugin/releases/tag/v7.0.0) |\n| 6.4.0     | tag v6.4.1 | v6.4.0            | Download: [v6.4.1](https://github.com/sing1ee/elasticsearch-jieba-plugin/releases/tag/v6.4.1) |\n| 6.0.0     | tag v6.0.0 | v6.0.0            | Download: [v6.0.1](https://github.com/sing1ee/elasticsearch-jieba-plugin/releases/tag/v6.0.1) |\n| 5.4.0     | tag v5.4.0 | v5.4.0            | Download: [v5.4.0](https://github.com/sing1ee/elasticsearch-jieba-plugin/releases/tag/v5.4.0) |\n| 5.3.0     | tag v5.3.0 | v5.3.0            | Download: [v5.3.0](https://github.com/sing1ee/elasticsearch-jieba-plugin/releases/tag/v5.3.0) |\n| 5.2.2     | tag v5.2.2 | v5.2.2            | Download: [v5.2.2](https://github.com/sing1ee/elasticsearch-jieba-plugin/releases/tag/v5.2.2) |\n| 5.2.1     | tag v5.2.1 | v5.2.1            | Download: [v5.2.1](https://github.com/sing1ee/elasticsearch-jieba-plugin/releases/tag/v5.2.1) |\n| 5.2       | tag v5.2.0 | v5.2.0            | Download: [v5.2.0](https://github.com/sing1ee/elasticsearch-jieba-plugin/releases/tag/v5.2.0) |\n| 5.1.2     | tag v5.1.2 | v5.1.2            | Download: [v5.1.2](https://github.com/sing1ee/elasticsearch-jieba-plugin/releases/tag/v5.1.2) |\n| 5.1.1     | tag v5.1.1 | v5.1.1            | Download: [v5.1.1](https://github.com/sing1ee/elasticsearch-jieba-plugin/releases/tag/v5.1.1) |\n\n---\n\n## 自定义用户词典\n\n将 `.dict` 后缀的词典文件放入 `${ES_HOME}/plugins/jieba/dic` 目录，格式如下：\n\n```\n小清新 3\n百搭 3\n显瘦 3\n隨身碟 100\n你的词语 词频\n```\n\n---\n\n## 使用停用词\n\n### 1. 创建停用词目录\n\n```shell\nmkdir -p ${ES_HOME}/config/stopwords\n```\n\n### 2. 复制停用词文件\n\n```shell\ncp ${ES_HOME}/plugins/jieba/dic/stopwords.txt ${ES_HOME}/config/stopwords/\n```\n\n### 3. 创建索引时配置分析器\n\n```shell\nPUT http://localhost:9200/jieba_index\n```\n\n```json\n{\n  \"settings\": {\n    \"analysis\": {\n      \"filter\": {\n        \"jieba_stop\": {\n          \"type\": \"stop\",\n          \"stopwords_path\": \"stopwords/stopwords.txt\"\n        },\n        \"jieba_synonym\": {\n          \"type\": \"synonym\",\n          \"synonyms_path\": \"synonyms/synonyms.txt\"\n        }\n      },\n      \"analyzer\": {\n        \"my_ana\": {\n          \"tokenizer\": \"jieba_index\",\n          \"filter\": [\n            \"lowercase\",\n            \"jieba_stop\",\n            \"jieba_synonym\"\n          ]\n        }\n      }\n    }\n  }\n}\n```\n\n### 4. 测试分析器\n\n```shell\nPOST http://localhost:9200/jieba_index/_analyze\n{\n  \"analyzer\": \"my_ana\",\n  \"text\": \"黄河之水天上来\"\n}\n```\n\n响应示例：\n\n```json\n{\n  \"tokens\": [\n    { \"token\": \"黄河\", \"start_offset\": 0, \"end_offset\": 2, \"type\": \"word\", \"position\": 0 },\n    { \"token\": \"黄河之水天上来\", \"start_offset\": 0, \"end_offset\": 7, \"type\": \"word\", \"position\": 0 },\n    { \"token\": \"之水\", \"start_offset\": 2, \"end_offset\": 4, \"type\": \"word\", \"position\": 1 },\n    { \"token\": \"天上\", \"start_offset\": 4, \"end_offset\": 6, \"type\": \"word\", \"position\": 2 },\n    { \"token\": \"上来\", \"start_offset\": 5, \"end_offset\": 7, \"type\": \"word\", \"position\": 2 }\n  ]\n}\n```\n\n---\n\n## License\n\nMIT License\n\n---\n\n## 致谢\n\n- 迁移自 [jieba-solr](https://github.com/sing1ee/jieba-solr)\n- 基于 [jieba](https://github.com/fxsjy/jieba) 中文分词\n- 感谢 [huaban](https://github.com/huaban) 提供的 jieba-analysis 依赖","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsing1ee%2Felasticsearch-jieba-plugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsing1ee%2Felasticsearch-jieba-plugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsing1ee%2Felasticsearch-jieba-plugin/lists"}