infinilabs /analysis-ik

🚌 The IK Analysis plugin integrates Lucene IK analyzer into Elasticsearch and OpenSearch, support customized dictionary.

★ 17,514⑂ 3,261👁 568⑃ 158● 998▤ 1
JavaApache-2.0Created 2011-12-16
下载:LatestLatest ↓Latest2024-05-06
-1
日增长
17,514
stars
3,261
forks
568
watchers
158
prs
998
issues
1
releases

README

IK Analysis for Elasticsearch and OpenSearch
==================================

!



The IK Analysis plugin integrates Lucene IK analyzer, and support customized dictionary.  It supports major versions of Elasticsearch and OpenSearch. Maintained and supported with ❤️ by INFINI Labs.

The plugin comprises analyzer: ik_smart , ik_max_word, and tokenizer: ik_smart , ik_max_word

 How to Install

 🚀 Get the Packaged Plugins

You can download the packaged plugins from here:  

https://release.infinilabs.com/

---

 🛠️ Install via CLI

Alternatively, you can use the plugin CLI to install the plugin. Here's how:

 For Elasticsearch:
bash
bin/elasticsearch-plugin install https://get.infini.cloud/elasticsearch/analysis-ik/9.1.4


 For OpenSearch:
bash
bin/opensearch-plugin install https://get.infini.cloud/opensearch/analysis-ik/2.12.0


---

 ⚠️ Tip  
Make sure to replace the version number with the one that matches your Elasticsearch or OpenSearch version.

 Getting Started

1.create a index

bash
curl -XPUT http://localhost:9200/index


2.create a mapping

bash
curl -XPOST http://localhost:9200/index/_mapping -H 'Content-Type:application/json' -d'
{
        "properties": {
            "content": {
                "type": "text",
                "analyzer": "ik_max_word",
                "search_analyzer": "ik_smart"
            }
        }

}'


3.index some docs

bash
curl -XPOST http://localhost:9200/index/_create/1 -H 'Content-Type:application/json' -d'
{"content":"美国留给伊拉克的是个烂摊子吗"}
'


bash
curl -XPOST http://localhost:9200/index/_create/2 -H 'Content-Type:application/json' -d'
{"content":"公安部:各地校车将享最高路权"}
'


bash
curl -XPOST http://localhost:9200/index/_create/3 -H 'Content-Type:application/json' -d'
{"content":"中韩渔警冲突调查:韩警平均每天扣1艘中国渔船"}
'


bash
curl -XPOST http://localhost:9200/index/_create/4 -H 'Content-Type:application/json' -d'
{"content":"中国驻洛杉矶领事馆遭亚裔男子枪击 嫌犯已自首"}
'


4.query with highlighting

bash
curl -XPOST http://localhost:9200/index/_search  -H 'Content-Type:application/json' -d'
{
    "query" : { "match" : { "content" : "中国" }},
    "highlight" : {
        "pre_tags" : ["", ""],
        "post_tags" : ["", ""],
        "fields" : {
            "content" : {}
        }
    }
}
'


Result

json
{
    "took": 14,
    "timed_out": false,
    "_shards": {
        "total": 5,
        "successful": 5,
        "failed": 0
    },
    "hits": {
        "total": 2,
        "max_score": 2,
        "hits": [
            {
                "_index": "index",
                "_type": "fulltext",
                "_id": "4",
                "_score": 2,
                "_source": {
                    "content": "中国驻洛杉矶领事馆遭亚裔男子枪击 嫌犯已自首"
                },
                "highlight": {
                    "content": [
                        "中国驻洛杉矶领事馆遭亚裔男子枪击 嫌犯已自首 "
                    ]
                }
            },
            {
                "_index": "index",
                "_type": "fulltext",
                "_id": "3",
                "_sco

Top issues

Latest release

Latest Latest 2024-05-06
IK Analysis for Elasticsearch and OpenSearch
==================================

!

 ! Breaking Change:
The latest version of the plugin packages are no longer release or upload to here, please check out the below instructions.

 How to Install

You can manulally download the packaged plugins from here: https://release.infinilabs.com,

or you can use the plugin cli to install the plugin like this:

For Elasticsearch

bin/elasticsearch-plugin install https://get.infini.cloud/elasticsearch/analysis-ik/8.4.1

For OpenSearch

bin/opensearch-plugin install https://get.infini.clo

Snapshot: 2026-11-16T09:23:14Z · Data license Apache-2.0 · JSON