es-07-head插件-ik分词器插件
5.x以后, es对head插件的支持并不是特别好
而且kibana的功能越来越强大, 建议使用kibana
1, head插件安装
在一台机器上安装head插件就可以了
1), 更新,安装依赖
sudo yum update -y
2), 安装npm
sudo yum install npm
yum -y install git
yum -y install bz2
3), github 地址
https://github.com/mobz/elasticsearch-head
4), 安装
git clone git://github.com/mobz/elasticsearch-head.git
cd elasticsearch-head
#编译安装
npm install
#
npm run start
5) docker的安装方式:
目前只支持到5.x
docker run -p : mobz/elasticsearch-head:
6), 在es的配置文件中
http.cors.enabled: true
http.cors.allow-orgin: "*"
7) 之后重启 es 和 head插件
npm run start
8), 之后可以通过
node1:9100 进行访问
2, ik分词器插件
需要在所有机器都可以进行安装
5.x版本之后的ik分词器, 可以直接在mapping中定义了, 但也可以通过安装插件的方式实现
githuib: https://github.com/medcl/elasticsearch-analysis-ik.git
1), 几种不同的分词模式:
ik_smart
: 智能分词, 粗力度
ik_max_word
: 最大词语, 细力度, 占用空间
2) 安装
有2种安装方式:
a), 直接使用es的插件下载安装
./bin/elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v6.3.0/elasticsearch-analysis-ik-6.3.0.zip
b) 手工安装
下载并解压到目录即可
plugins 目录下必须包含一层目录才可以
create plugin folder cd your-es-root/plugins/ && mkdir ik unzip plugin to folder your-es-root/plugins/ik
3), 之后创建使用ik
create index
put index_name
create mapping
POST index_name
{
"mappings": {
{
"properties": {
"content": {
"type": "text",
"analyzer": "ik_max_word",
"search_analyzer": "ik_max_word"
}
} }
}
4) 插入数据进行查询
curl -XPOST http://localhost:9200/index/fulltext/1 -H 'Content-Type:application/json' -d'
{"content":"美国留给伊拉克的是个烂摊子吗"}
'
curl -XPOST http://localhost:9200/index/fulltext/2 -H 'Content-Type:application/json' -d'
{"content":"公安部:各地校车将享最高路权"}
'
curl -XPOST http://localhost:9200/index/fulltext/3 -H 'Content-Type:application/json' -d'
{"content":"中韩渔警冲突调查:韩警平均每天扣1艘中国渔船"}
'
curl -XPOST http://localhost:9200/index/fulltext/4 -H 'Content-Type:application/json' -d'
{"content":"中国驻洛杉矶领事馆遭亚裔男子枪击 嫌犯已自首"}
'
查询
curl -XPOST http://localhost:9200/index/fulltext/_search -H 'Content-Type:application/json' -d'
{
"query" : { "match" : { "content" : "中国" }},
"highlight" : {
"pre_tags" : ["<tag1>", "<tag2>"],
"post_tags" : ["</tag1>", "</tag2>"],
"fields" : {
"content" : {}
}
}
}
'
5), 配置自己的字典等
{plugins}/elasticsearch-analysis-ik-*/config/IKAnalyzer.cfg.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
<properties>
<comment>IK Analyzer 扩展配置</comment>
<!--用户可以在这里配置自己的扩展字典 -->
<entry key="ext_dict">custom/mydict.dic;custom/single_word_low_freq.dic</entry>
<!--用户可以在这里配置自己的扩展停止词字典-->
<entry key="ext_stopwords">custom/ext_stopword.dic</entry>
<!--用户可以在这里配置远程扩展字典 -->
<entry key="remote_ext_dict">location</entry>
<!--用户可以在这里配置远程扩展停止词字典-->
<entry key="remote_ext_stopwords">http://xxx.com/xxx.dic</entry>
</properties>
6), 配置热更新词典
<!--用户可以在这里配置远程扩展字典 -->
<entry key="remote_ext_dict">location</entry>
<!--用户可以在这里配置远程扩展停止词字典-->
<entry key="remote_ext_stopwords">location</entry>
7), 如果分词测试失败了, 使用
curl -XGET "http://localhost:9200/_analyze?pretty&analyzer=ik_smart' -d '中华人民共和国M'
8), 不建立索引的测试ik分词器
GET _analyze?pretty
{
"analyzer": "ik_smart",
"text":"安徽省长江流域"
}
最后贴一个别人家的mapping
dynamic: true。 可以存储更多的属性, 但使用默认规则
es-07-head插件-ik分词器插件的更多相关文章
- IK分词器插件elasticsearch-analysis-ik 6.1.1
http://88250.b3log.org/full-text-search-elasticsearch#b3_solo_h3_0 IK分词器插件 (1)源码 https://github.com/ ...
- docker上安装elasticsearch和ik分词器插件和header,实现分词功能
docker run -di --name=tensquare_es -p 9200: -p 9300:9300 elasticsearch:5.6.8 创建elasticsearch容器(如果版本不 ...
- Linux下,非Docker启动Elasticsearch 6.3.0,安装ik分词器插件,以及使用Kibana测试Elasticsearch,
Linux下,非Docker启动Elasticsearch 6.3.0 查看java版本,需要1.8版本 java -version yum -y install java 创建用户,因为elasti ...
- Elasticsearch 7.x - IK分词器插件(ik_smart,ik_max_word)
一.安装IK分词器 Elasticsearch也需要安装IK分析器以实现对中文更好的分词支持. 去Github下载最新版elasticsearch-ik https://github.com/medc ...
- IK分词器插件
(1)源码 https://github.com/medcl/elasticsearch-analysis-ik (2)releases https://github.com/medcl/elast ...
- es的插件 ik分词器的安装和使用
今天折腾了一天,在es 5.5.0 上安装ik.一直通过官方给定的命令没用安装成功,决定通过手工是形式进行安装.https://github.com/medcl/elasticsearch-analy ...
- 通过docker安装elasticsearch和安装ik分词器插件及安装kibana
前提: 已经安装好docker运行环境: 步骤: 1.安装elasticsearch 6.2.2版本,目前最新版是7.2.0,这里之所以选择6.2.2是因为最新的SpringBoot2.1.6默认支持 ...
- windows elasticsearch使用ik分词器插件后启动报错java.security.AccessControlException: access denied ("java.io.FilePermission" "D:...........\plugins\ik-analyzer\config\IKAnalyzer.cfg.xml" "read")
删除es安装文件夹中空格,遂解决......(哭
- Elastic Stack 笔记(二)Elasticsearch5.6 安装 IK 分词器和 Head 插件
博客地址:http://www.moonxy.com 一.前言 Elasticsearch 作为开源搜索引擎服务器,其核心功能在于索引和搜索数据.索引是把文档写入 Elasticsearch 的过程, ...
随机推荐
- CentOS 6.0 安装配置rails 2.3.11 + redmine 1.2.1 笔记
没想到安装过程这么曲折,gem安装时下载经常是不成功的,无耐只好把.gem文件下载回来再本地安装,加上radmine 1.2.1对各组件的版本了也比较挑剔,中间走了不少弯路,折腾了二天时间,终于摸清路 ...
- tarjan算法的补充POJ2533tarjan求度
做题时又遇到了疑惑,说明一开始就没有完全理解 基于dfs的tarjan,搜索时会有四种边 树枝边:DFS 时经过的边,即 DFS 搜索树上的边 前向边:与 DFS 方向一致,从某个结点指向其某个子孙的 ...
- 区间DP石子合并问题 & 四边形不等式优化
入门区间DP,第一个问题就是线性的规模小的石子合并问题 dp数组的含义是第i堆到第j堆进行合并的最优值 就是说dp[i][j]可以由dp[i][k]和dp[k+1][j]转移过来 状态转移方程 dp[ ...
- ASP.NET Web API 入门 (API接口、寄宿方式、HttpClient调用)
一.ASP.NET Web API接口定义 ASP.NET Web API默认实现了Action方法和HTTP方法的映射,Action方法方法名体现了其能处理的请求必须采用的HTTP方法 二.寄宿方式 ...
- EBS 定义显示总帐快码设置
自定义一个功能如下,挂到菜单上就可以了功能 用户功能名 表单 参数GL_GLXDQMLK(自定义) 总帐代码列表 定义代码 VIEW_APPLICATION="SQLGL" HEL ...
- 1. Ubuntu下MongoDB的安装和使用
一.MongoDB介绍 MongoDB 是一个是一个基于分布式文件存储的数据库,介于关系数据库和非关系数据库之间,是非关系数据库当中功能最丰富,最像关系数据库的.他支持的数据结构非常松散,是类似jso ...
- Memcached和Memcache安装(64位win2008)
一.Memcached和Memcache的区别: 网上关于Memcached和Memcache的区别的理解众说纷纭,我个人的理解是: Memcached是一个内存缓存系统,而Memcache是php的 ...
- Latex 表格(跨行、跨列、背景加灰)new
一. 效果如图 二.代码如下 1. 首部增加宏包: \usepackage{multirow} 2. 正文部分增加: \begin{table} \centering \caption{Suspici ...
- php file_get_contents fopen 连接远程文件
使用file_get_contents和fopen必须空间开启allow_url_fopen. 方法: 编辑php.ini,设置allow_url_fopen =true On,allow_url_f ...
- 一步步改造wcf,数据加密传输-匿名客户端加密传输
一步步改造wcf,数据加密传输-匿名客户端加密传输 百度搜索wcf加密传输,资料挺多,真真正正能用的确不多. 一是本来就很复杂,而是各位大神给的资料不足.本人今天来提供一个简易方法. 匿名客户端加密传 ...