1.下载

elsticsearch下载地址:Elasticsearch:官方分布式搜索和分析引擎 | Elastic 下载好自己的版本后解压到自己的安装目录。

如下图:

解压文件后如下图,点击

启动:

直接启动有的框架是必须要求es 是有密码的 所以我们要给我们的es 设置密码步骤如下:

在文件最下面配置如下:

http.cors.enabled: true http.cors.allow-origin: "*" http.cors.allow-headers: Authorization xpack.security.enabled: true xpack.security.transport.ssl.enabled: true

注意:设置密码的时候es 需要是在启动状态下设置的 否则会报错

配置好配置文件后 执行下方命令 需要cmd 到 es 的 bin 目录下

elasticsearch-setup-passwords interactive

执行命令后会让你输入4-5个密码全部一样就好了 我自己设置的elastic/elastic

重启es后浏览器 127.0.0.1:9200 会看到如下页面,输入自己刚才设置的账号密码后 看到图2则说明自己的账号密码设置成功

图1

图2

2.安装kinbana 和es以及cebero

kibana下载地址:Download Kibana Free | Get Started Now | Elastic

注意:切记es和kibana的版本必须是一致的 

3.分词器

下载好的分词器解压到自己es 的plugin 目录下面,如图是我这边下载好的自己分词器

ik 分词器下载安装地址: https://github.com/medcl/elasticsearch-analysis-ik/releases

icu分词器下载安装地址:https://artifacts.elastic.co/downloads/elasticsearch-plugins/analysis-icu/analysis-icu-6.8.1.zip(注意自己替换自己对应的版本)

smartcn分词器下载地址:https://artifacts.elastic.co/downloads/elasticsearch-plugins/analysis-smartcn/analysis-smartcn-7.9.0.zip

ansj分词器下载地址:https://github.com/NLPchina/elasticsearch-analysis-ansj(已经很久没有更新了,作者自己很喜欢这个分词器,中英文分词都能很好支持,最后支持到7.9.3)

smartcn分词器下载安装地址

4.踩坑记录

1.kibana 、 各种分词器的版本 下载的必须与elasticsearch的版本相同 否则会出现闪退的情况

2. 页面结果太大 {"error":{"root_cause":[{"type":"query_phase_execution_exception","reason":"Result window is too large, from + size must be less than or equal to: [10000] but was [100001]. See the scroll api for a more efficient way to request large data sets. This limit can be set by changing the [index.max_result_window] index level setting."}],"type":"search_phase_execution_exception","reason":"all shards failed","phase":"query","grouped":true,"failed_shards":[{"shard":0,"index":"dms-apply-info","node":"IZhu6TvHSh-jm0rinE0f2A","reason":{"type":"query_phase_execution_exception","reason":"Result window is too large, from + size must be less than or equal to: [10000] but was [100001]. See the scroll api for a more efficient way to request large data sets. This limit can be set by changing the [index.max_result_window] index level setting."}}]},"status":500}

解决:

PUT your_index/_doc/_setting

{ "index" : { "max_result_window" : 50000000}}

5. ES使用教程

1.文档教程:Elasticsearch: 权威指南 | Elastic

2.一个index 使用两个分词器 使用一个分词器查询

################ik ik_max_word: 将需要分词的文本做最小粒度的拆分,尽量分更多的词。

##ik_smart: 将需要分词的文本做最大粒度的拆分。

PUT /article04

{

"mappings": {

"properties": {

"title": {

"type": "text",

"analyzer": "ik_max_word",

"fields":{"std":{"type":"text","analyzer":"standard"}}

}

}

}

}

GET article04

POST article04/_doc/3

{"title":"甩泪大促销"}

POST article04/_doc/2

{"title":"百度一下,你就知道"}

POST article04/_doc/4

{"title":"中心思想"}

POST article04/_doc/5

{"title":"国家战略"}

GET article04/_doc/_search

{"query":{"match": {

"fields.std": {

"query": "中",

"analyzer": "standard"

}

}}}

(使用一个分词器匹配两个分词器)

GET article04/_doc/_search

{

"query": {

"multi_match": {

"query": "www",

"type": "most_fields",

"fields": [ "title", "title.std" ]

}

}

}

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐