ElasticSearch 安装中文分词器
1、安装中文分词器IK
下载地址:https://github.com/medcl/elasticsearch-analysis-ik
在线下载安装: elasticsearch-plugin.bat install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v5.5.2/elasticsearch-analysis-ik-5.5.2.zip
先下载后安装:elasticsearch-plugin.bat install file:///D:\work\ElasticSearch\plugin\elasticsearch-analysis-ik-5.5.2.zip



2、重启 elasticsearch
3、创建空索引
curl -XPUT http://127.0.0.1:9200/index_china

或
在kibana的Dev Tools中用 PUT /index_american/

4、创建映射
curl -XPOST http://127.0.0.1:9200/index_china/fulltext/_mapping -d "{\"properties\": {\"content\": {\"type\": \"text\",\"analyzer\": \"ik_max_word\",\"search_analyzer\": \"ik_max_word\"}}}"

或
POST /index_american/fulltext/_mapping
{
"properties":
{
"content":
{
"type": "text",
"analyzer":
"ik_max_word",
"search_analyzer": "ik_max_word"
}
}
}

5、索引数据
POST /index_china/fulltext
{
"content" : "中国是世界上人口最多的国家",
"title" : "中国",
"tags" : [ "中国", "人口" ]
}

批量索引数据
POST /_bulk
{ "create": { "_index": "index_china", "_type": "fulltext", "_id": } }
{ "title": "周星驰最新电影" }
{ "create": { "_index": "index_china", "_type": "fulltext", "_id": } }
{ "title": "周星驰最好看的新电影" }
{ "create": { "_index": "index_china", "_type": "fulltext", "_id": } }
{ "title": "周星驰最新电影,最好,新电影" }
{ "create": { "_index": "index_china", "_type": "fulltext", "_id": } }
{ "title": "最最最最好的新新新新电影" }
{ "create": { "_index": "index_china", "_type": "fulltext", "_id": } }
{ "title": "I'm not happy about the foxes" }
6、查询
GET /index_china/fulltext/_search
{
"query": {
"match": {
"content": "中国"
}
}
}


7、最大分词和最小分词
ik_smart,
ik_max_word


GET /_analyze
{
"analyzer": "ik_smart",
"text": "中华人民共和国"
}
GET /_analyze
{
"analyzer": "ik_max_word",
"text": "中华人民共和国"
}
#删除索引
DELETE /ott_test #创建索引 PUT /ott_test
{
"mappings": {
"ott_type" : {
"properties" : {
"title" : {
"type" : "text",
"index":true,
"analyzer": "ik_max_word",
"search_analyzer": "ik_max_word"
},
"date" : {
"type" : "date"
},
"keyword" : {
"type" : "keyword"
},
"source" : {
"type" : "keyword"
},
"link" : {
"type" : "keyword"
}
}
}
}
} #索引数据
POST /ott_test/ott_type
{
"title":"微博新规惹争议:用户原创内容版权归属于微博?",
"link":"http://www.yidianzixun.com/article/0HHoxgVq",
"date":"2017-09-17",
"source":"虎嗅网",
"keyword":"内容"
} #分析
GET /ott_test/_analyze
{
"field": "title",
"text": "内容"
} #查询 GET /ott_test/ott_type/_search
{
"query": {
"match": {
"title": "内容"
}
}
} #只查询title和date两个字段的数据 GET /ott_test/ott_type/_search
{
"query": {"match_all": {}},
"_source": ["title","date"]
}
ElasticSearch 安装中文分词器的更多相关文章
- 如何给Elasticsearch安装中文分词器IK
安装Elasticsearch安装中文分词器IK的步骤: 1. 停止elasticsearch 2.2的服务 2. 在以下地址下载对应的elasticsearch-analysis-ik插件安装包(版 ...
- elasticsearch安装中文分词器插件smartcn
原文:http://blog.java1234.com/blog/articles/373.html elasticsearch安装中文分词器插件smartcn elasticsearch默认分词器比 ...
- ElasticSearch安装中文分词器IKAnalyzer
# ElasticSearch安装中文分词器IKAnalyzer 本篇主要讲解如何在ElasticSearch中安装中文分词器IKAnalyzer,拆分的每个词都是我们熟知的词语,从而建立词汇与文档 ...
- ElasticSearch安装中文分词器IK
1.安装IK分词器,下载对应版本的插件,elasticsearch-analysis-ik中文分词器的开发者一直进行维护的,对应着elasticsearch的版本,所以选择好自己的版本即可.IKAna ...
- elasticsearch安装中文分词器
1. 分词器的安装 ./bin/elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/rele ...
- 如何在Elasticsearch中安装中文分词器(IK)和拼音分词器?
声明:我使用的Elasticsearch的版本是5.4.0,安装分词器前请先安装maven 一:安装maven https://github.com/apache/maven 说明: 安装maven需 ...
- Elasticsearch之中文分词器插件es-ik(博主推荐)
前提 什么是倒排索引? Elasticsearch之分词器的作用 Elasticsearch之分词器的工作流程 Elasticsearch之停用词 Elasticsearch之中文分词器 Elasti ...
- 沉淀再出发:ElasticSearch的中文分词器ik
沉淀再出发:ElasticSearch的中文分词器ik 一.前言 为什么要在elasticsearch中要使用ik这样的中文分词呢,那是因为es提供的分词是英文分词,对于中文的分词就做的非常不好了 ...
- Elasticsearch之中文分词器插件es-ik的自定义热更新词库
不多说,直接上干货! 欢迎大家,关注微信扫码并加入我的4个微信公众号: 大数据躺过的坑 Java从入门到架构师 人工智能躺过的坑 Java全栈大联盟 ...
随机推荐
- [洛谷P4630][APIO2018] Duathlon 铁人两项
题目大意:给一张无向图,求三元组$(u,v,w)$满足$u->v->w$为简单路径,求个数 题解:圆方树,缩点后$DP$,因为同一个点双中的点一定地位相同 卡点:1.$father$数组开 ...
- [YNOI2017][bzoj4811][luogu3613] 由乃的OJ/睡觉困难综合症 [压位+树链剖分+线段树]
题面 BZOJ题面,比较不清晰 Luogu题面,写的比较清楚 思路 原题目 我们先看这道题的原题目NOI2014起床困难综合症 的确就是上树的带修改版本 那么我们先来解决这个原版的序列上单次询问 二进 ...
- 【CF Round 439 E. The Untended Antiquity】
time limit per test 2 seconds memory limit per test 512 megabytes input standard input output standa ...
- 【CZY选讲·一道图论好题】
题目描述 LYK有一张无向图G={V,E},这张无向图有n个点m条边组成.并且这是一张带权图,不仅有边权还有点权.LYK给出了一个子图的定义,一张图G'={V',E'}被称作G的子图,当且仅当: · ...
- 《R语言实战》读书笔记--第二章 创建数据集
2.1数据集的概念 变量的类型是不同的,比如标示符.日期变量.连续变量.名义变量.有序型变量等,记得数据挖掘导论中有专门的描述. R可以处理的数据类型包括了数值型.字符型.逻辑型.复数型(虚数).原生 ...
- Winform 模拟Session
背景 在Web中Session的功能很好用,于是想Winform中实现该功能,典型应用场景则是登陆成功后,当一段时间不操作,则该会话过期,提示重新登陆. 资源下载 测试代码 示例说明:登陆进去10s不 ...
- gdb 打印内存 x
GNU gdb (Ubuntu -0ubuntu1~ Copyright (C) Free Software Foundation, Inc. License GPLv3+: GNU GPL vers ...
- 组合数问题(NOIP2016)
原题传送门 这题啊. 裸的杨辉三角. 预处理杨辉三角和答案即可 下面贴代码 #include<iostream> #include<cstdio> #include<al ...
- 第3章 MFC框架程序剖析
参考: https://blog.csdn.net/u014162133/article/details/46573873 1. 2.MFC简介:MFC(Microsoft Foundation Cl ...
- UVA 10985 Rings'n'Ropes
最短路 参考了Staingger的博客 感觉DP的状态记录还是有毛病.可以DFS寻找结果也. #include <map> #include <set> #include &l ...