一、es安装
1.1、配置
config/elasticsearch.yml
# 打开节点名称node.name: chb2# 这里的node-1为node-name配置的值cluster.initial_master_nodes:["chb2"]# 外部ip访问elasticsearchnetwork.host: 0.0.0.0
1.2、Ps:常见报错
[1]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
elasticsearch用户拥有的内存权限太小,至少需要262144;
//需要切换到root用户sysctl -w vm.max_map_count=262144//查看结果sysctl -a|grep vm.max_map_count//显示vm.max_map_count = 262144//修改之后,如果重启虚拟机将失效!!!//解决办法://在 /etc/sysctl.conf文件最后添加一行vm.max_map_count=262144
[2]: the default discovery settings are unsuitable for production use; at least one of [discovery.seed_hosts, discovery.seed_providers, cluster.initial_master_nodes] must be configured
修改ES配置文件:config/elasticsearch.yml
//解开注释cluster.initial_master_nodes: ["node-1", "node-2"]
二、kibana安装
vim kibana.yml
server.port: 5601server.host: "0.0.0.0"elasticsearch.hosts: ["http://192.168.200.110:9200"]
2.2、问题
2.2.1、Error: Could not close browser client handle!
在kibana的config中的kibana.yml中配置
elasticsearch.hosts: [“http://192.168.147.52:9200”]xpack.reporting.capture.browser.chromium.disableSandbox: truexpack.reporting.capture.browser.chromium.proxy.enabled: falsexpack.reporting.enabled: false
详细请参考:
https://www.elastic.co/guide/en/kibana/current/settings.html kibana官方配置
/sanduzxcvbnm/p/12677691.html
/yun/34216.html
三、ik分词器
3.1、ik配置
1、下载ik分词器 /medcl/elasticsearch-analysis-ik/releases/tag/v7.9.3
2、解压到es的plugins目录下
3、重启es
3.2、配置自定义词库
1、配置自定义词库文件
对于部分专业词语,我们不想进行分词,所以ik分词器提供自定义词库
修改plugins/ik/config/IKAnalyzer.cfg.xml,可以使用本地自定义词库,也可以使用远程分词库(建议使用远程,这样不用每次重启es集群)
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE properties SYSTEM "/dtd/properties.dtd"><properties><comment>IK Analyzer 扩展配置</comment><!--用户可以在这里配置自己的扩展字典 --><entry key="ext_dict">custom.dic</entry><!--用户可以在这里配置自己的扩展停止词字典--><entry key="ext_stopwords"></entry><!--用户可以在这里配置远程扩展字典 --><!-- <entry key="remote_ext_dict">words_location</entry> --><!--用户可以在这里配置远程扩展停止词字典--><!-- <entry key="remote_ext_stopwords">words_location</entry> --></properties>
3、重启es
配置自定义词库前
配置自定义词库后
四、同义词
4.1、配置
1、配置同义词词库
2、重启
3、创建索引,设置settings
PUT test1{"settings": {"number_of_shards": 1,"number_of_replicas": 1,"analysis": {"filter": {"word_sync": {"type": "synonym","synonyms_path": "analysis/synonym.txt"}},"analyzer": {"ik_sync_smart": {"filter": ["word_sync"],"type": "custom","tokenizer": "ik_smart"}}}},"mappings": {"properties": {"name": {"type": "text","fields": {"synoword": {"type": "text","analyzer": "ik_sync_smart"}}}}}}
五、拼音
5.1、配置pinyin插件
1、下载plugin /medcl/elasticsearch-analysis-pinyin/releases/tag/v7.9.3
2、解压刀plugins目录下的pinyin目录
3、重启es
5.4、测试拼音
六、综合
1、创建index
PUT test1{"settings": {"number_of_shards": 1,"number_of_replicas": 1,"analysis": {"filter": {"word_sync": {"type": "synonym","synonyms_path": "analysis/synonym.txt"}},"analyzer": {"ik_sync_smart": {"filter": ["word_sync"],"type": "custom","tokenizer": "ik_smart"},"pinyin_analyzer": {"type": "custom","tokenizer": "pinyin_tokenizer"}},"tokenizer": {"pinyin_tokenizer": {"type": "pinyin"}}}},"mappings": {"properties": {"name": {"type": "text","fields": {"synoword": {"type": "text","analyzer": "ik_sync_smart"},"pinyin": {"type": "text","analyzer": "pinyin_analyzer"}}}}}}
2、添加数据
PUT test1/_doc/1{"name": "全季"}PUT test1/_doc/2{"name": "拳击馆"}PUT test1/_doc/3{"name": "汉庭"}
3、查询