elasticsearch-analysis-jieba开源项目

我要开发同款
匿名用户2013年08月29日
41阅读
开发技术Java
所属分类程序开发、中文分词库
授权协议Apache

作品详情

结巴分词插件(forelasticsearch),目前支持0.90.*以上版本

----------------------------------------------------|JiebaChineseAnalysisPlugin|ElasticSearch|----------------------------------------------------|0.0.1-SNAPSHOT(master)|0.90.*|----------------------------------------------------

支持两种分词模式(seg_mode):

index索引模式,搜索引擎建立索引阶段使用该模式search搜索模式,搜索时采用该种模式分词使用说明

创建mapping

#!/bin/bashcurl-XDELETE'0:9200/test/';echocurl-XPUT'0:9200/test/'-d'{"index":{"number_of_shards":1,"number_of_replicas":0,"analysis":{"analyzer":{"jieba_search":{"type":"jieba","seg_mode":"search","stop":true},"jieba_index":{"type":"jieba","seg_mode":"index","stop":true}}}}}';echo

test

#indexmodecurl'0:9200/test/_analyze?analyzer=jieba_index'-d'中华人民共和国';echo

结果:

{"tokens":[{"token":"中华","start_offset":0,"end_offset":2,"type":"word","position":1},{"token":"华人","start_offset":1,"end_offset":3,"type":"word","position":2},{"token":"人民","start_offset":2,"end_offset":4,"type":"word","position":3},{"token":"共和","start_offset":4,"end_offset":6,"type":"word","position":4},{"token":"共和国","start_offset":4,"end_offset":7,"type":"word","position":5},{"token":"中华人民共和国","start_offset":0,"end_offset":7,"type":"word","position":6}]}#searchmodecurl'0:9200/test/_analyze?analyzer=jieba_search'-d'中华人民共和国';echo

结果:

{"tokens":[{"token":"中华人民共和国","start_offset":0,"end_offset":7,"type":"word","position":1}]}
声明:本文仅代表作者观点,不代表本站立场。如果侵犯到您的合法权益,请联系我们删除侵权资源!如果遇到资源链接失效,请您通过评论或工单的方式通知管理员。未经允许,不得转载,本站所有资源文章禁止商业使用运营!
下载安装【程序员客栈】APP
实时对接需求、及时收发消息、丰富的开放项目需求、随时随地查看项目状态

评论