ES上使用IK中文分词器 es-ik

码农软件 · 软件分类 · 中文分词库 · 2019-08-28 20:13:38

软件介绍

IK中文分词器在Elasticsearch上的使用。原生IK中文分词是从文件系统中读取词典,es-ik本身可扩展成从不同的源读取词典。目前提供从sqlite3数据库中读取。es-ik-plugin-sqlite3使用方法:

1. 在elasticsearch.yml中设置你的sqlite3词典的位置:

ik_analysis_db_path: /opt/ik/dictionary.db

我提供了默认的词典:https://github.com/zacker330/es-ik-sqlite3-dictionary

2. 安装(目前是1.0.1版本)

./bin/plugin -i ik-analysis -u https://github.com/zacker330/es-ik-plugin-sqlite3-release/raw/master/es-ik-sqlite3-1.0.1.zip

3. 现在可以测试了:

    1. 创建index

curl -X PUT -H "Cache-Control: no-cache" -d '{
    "settings":{
        "index":{
            "number_of_shards":1,
            "number_of_replicas": 1
        }
    }
}' 'http://localhost:9200/songs/'

      2. 创建map:

curl -X PUT -H "Cache-Control: no-cache" -d '{
        "song": {
            "_source": {"enabled": true},
            "_all": {
                "indexAnalyzer": "ik_analysis",
                "searchAnalyzer": "ik_analysis",
                "term_vector": "no",
                "store": "true"
            },
            "properties":{
                "title":{
                    "type": "string",
                    "store": "yes",
                    "indexAnalyzer": "ik_analysis",
                    "searchAnalyzer": "ik_analysis",
                    "include_in_all": "true"
                }
            }

        }
}
    ' 'http://localhost:9200/songs/_mapping/song'

       3.

curl -X POST  -d '林夕为我们作词' 'http://localhost:9200/songs/_analyze?analyzer=ik_analysis'

response:
{"tokens":[{"token":"林夕","start_offset":0,"end_offset":2,"type":"CN_WORD","position":1},{"token":"作词","start_offset":5,"end_offset":7,"type":"CN_WORD","position":2}]}

本文地址:https://www.codercto.com/soft/d/13381.html

码农翻身

码农翻身

刘欣 / 电子工业出版社 / 2018-6-1 / 69.00元

《码农翻身》用故事的方式讲解了软件编程的若干重要领域,侧重于基础性、原理性的知识。 《码农翻身》分为6章。第1章讲述计算机的基础知识;第2章侧重讲解Java的基础知识;第3章偏重Web后端编程;第4章讲解代码管理的本质;第5章讲述了JavaScript的历史、Node.js的原理、程序的链接、命令式和声明式编程的区别,以及作者十多年来使用各种编程语言的感受;第6章是作者的经验总结和心得体会,......一起来看看 《码农翻身》 这本书的介绍吧!

JSON 在线解析
JSON 在线解析

在线 JSON 格式化工具

MD5 加密
MD5 加密

MD5 加密工具

html转js在线工具
html转js在线工具

html转js在线工具