程序员开发实例大全宝库

网站首页 > 编程文章 正文

ElasticSearch 插件部署及介绍(elasticsearch插件安装)

zazugpt 2024-09-10 23:35:13 编程文章 28 ℃ 0 评论

ElasticSearch 插件部署及介绍

一:sense 编辑器

https://www.elastic.co/guide/en/sense/current/installing.html

bin/kibana plugin --install elastic/sense


二:marvel 监视器

https://www.elastic.co/downloads/marvel

Step 1: Install Marvel into Elasticsearch:

bin/plugin install license

bin/plugin install marvel-agent

Step 2: Install Marvel into Kibana

bin/kibana plugin --install elasticsearch/marvel/latest

Step 3: Start Elasticsearch and Kibana

bin/elasticsearch

bin/kibana

Step 4: Navigate to http://localhost:5601/app/marvel


三:kibana 数据展示器

https://www.elastic.co/guide/en/kibana/current/introduction.html


四:maven 插件安装

maven 插件安装 匹配 elasticsearch-analysis-ik

地址:http://maven.apache.org/download.html

文件:

http://mirrors.hust.edu.cn/apache/maven/maven-3/3.3.1/binaries/apache-maven-3.3.1-bin.tar.gz

tar zxvf apache-maven-3.3.1-bin.tar.gz

cp -rf apache-maven-3.3.1 /usr/local/apache-maven-3.3.1

cp -rf apache-maven-3.3.9 /usr/local/apache-maven-3.3.9


设置环境变量:

export M2_HOME=/usr/local/apache-maven-3.3.1

export PATH=$PATH:$M2_HOME/bin

编辑~/.bashrc文件

/etc/profile

export M2_HOME=/usr/local/apache-maven-3.3.1

export PATH=$PATH:$M2_HOME/bin

vi /etc/profile

#mvn

export M2_HOME=/usr/local/apache-maven-3.3.9

export PATH=$PATH:$M2_HOME/bin

source /etc/profile


检测环境:

echo $M2_HOME

mvn -version

Apache Maven 3.3.1 (cab6659f9874fa96462afef40fcf6bc033d58c1c; 2015-03-14T04:10:27+08:00)

Maven home: /usr/local/apache-maven-3.3.1

Java version: 1.7.0_55, vendor: Oracle Corporation

Java home: /usr/java/jdk1.7.0_55/jre

Default locale: en_US, platform encoding: UTF-8

OS name: "linux", version: "3.10.5-3.el6.x86_64", arch: "amd64", family: "unix"

下载地址:

https://github.com/medcl/elasticsearch-analysis-ik

cd elasticsearch-analysis-ik mvn clean mvn compile mvn package



四:中文分词

curl -XPUT localhost:9200/local -d '{

"settings" : {

"analysis" : {

"analyzer" : {

"ik" : {

"tokenizer" : "ik"

}

}

}

},

"mappings" : {

"article" : {

"dynamic" : true,

"properties" : {

"title" : {

"type" : "string",

"analyzer" : "ik"

}

}

}

}

}'

curl 'http://192.168.211.136:9200/local/_analyze?analyzer=ik&pretty=true' -d'

{

"text":"中华人民共和国国歌"

} '

curl 'http://localhost:9200/local/_analyze?analyzer=ik&pretty=true' -d'

{

"text":"中华人民共和国国歌"

} '

{

"tokens" : [ {

"token" : "text",

"start_offset" : 10,

"end_offset" : 14,

"type" : "ENGLISH",

"position" : 1

}, {

"token" : "中华人民共和国",

"start_offset" : 17,

"end_offset" : 24,

"type" : "CN_WORD",

"position" : 2

}, {

"token" : "中华人民",

"start_offset" : 17,

"end_offset" : 21,

"type" : "CN_WORD",

"position" : 3

}, {

"token" : "中华",

"start_offset" : 17,

"end_offset" : 19,

"type" : "CN_WORD",

"position" : 4

}, {

"token" : "华人",

"start_offset" : 18,

"end_offset" : 20,

"type" : "CN_WORD",

"position" : 5

}, {

"token" : "人民共和国",

"start_offset" : 19,

"end_offset" : 24,

"type" : "CN_WORD",

"position" : 6

}, {

"token" : "人民",

"start_offset" : 19,

"end_offset" : 21,

"type" : "CN_WORD",

"position" : 7

}, {

"token" : "共和国",

"start_offset" : 21,

"end_offset" : 24,

"type" : "CN_WORD",

"position" : 8

}, {

"token" : "共和",

"start_offset" : 21,

"end_offset" : 23,

"type" : "CN_WORD",

"position" : 9

}, {

"token" : "国",

"start_offset" : 23,

"end_offset" : 24,

"type" : "CN_CHAR",

"position" : 10

}, {

"token" : "国歌",

"start_offset" : 24,

"end_offset" : 26,

"type" : "CN_WORD",

"position" : 11

} ]

}

新下载的ES是1.4.2版本的,所以会出现问题 。

2.用plugin -i medcl/elasticsearch-analysis-ik 无法安装成功,应该也是 版本的问题

3.编译安装elasticsearch-analysis-ik

用需要用到maven,第一次用maven编译时间需要很长,大部分时间都是在下载依赖包,依赖包可在~/.m2中找到

在源码目录下执行 mvn package

编译完成后在target/releases目录下有个elasticsearch-analysis-ik-1.2.9.zip文件,将其拷贝到plugins/analysis-ik中解压缩即可

词库将源码包中的config/ik拷贝到ES目录下就可以了,不用作其它配置,方法参考项目主页的方法。

4.配置,在config/elasticsearch.yml中添加下行

index.analysis.analyzer.ik.type : "ik"

直接运行,看到无错误的话,说明ik装成功

2.3 版本分词

1、创建一个索引,名为index。

curl -XPUT http://192.168.211.136:9200/index

2、为索引index创建mapping。

curl -XPOST http://192.168.211.136:9200/index/fulltext/_mapping -d'

{

"fulltext": {

"_all": {

"analyzer": "ik"

},

"properties": {

"content": {

"type" : "string",

"boost" : 8.0,

"term_vector" : "with_positions_offsets",

"analyzer" : "ik",

"include_in_all" : true

}

}

}

}'

3、测试

curl 'http://192.168.211.136:9200/index/_analyze?analyzer=ik&pretty=true' -d '

{

"text":"世界如此之大"

}'

显示结果如下:

{

"tokens" : [ {

"token" : "世界",

"start_offset" : 0,

"end_offset" : 2,

"type" : "CN_WORD",

"position" : 0

}, {

"token" : "如此之",

"start_offset" : 2,

"end_offset" : 5,

"type" : "CN_WORD",

"position" : 1

}, {

"token" : "如此",

"start_offset" : 2,

"end_offset" : 4,

"type" : "CN_WORD",

"position" : 2

}, {

"token" : "之大",

"start_offset" : 4,

"end_offset" : 6,

"type" : "CN_WORD",

"position" : 3

} ]

}

Tags:

本文暂时没有评论,来添加一个吧(●'◡'●)

欢迎 发表评论:

最近发表
标签列表