做集群
修改配置文件elasticsearch.yml
cluster.name: my-es
node.name: node-1
node.master: true
node.data: true
http.port: 9200
transport.tcp.port: 9300
network.host: 0.0.0.0
discovery.zen.ping.unicast.hosts: ["127.0.0.1", "127.0.0.1:8300"]
node.max_local_storage_nodes: 2
#discovery.zen.ping_timeout: 30s #设置超时时间,一般来说网络不是很稳定的话设置长一点
#discovery.zen.minimum_master_nodes: 2 #至少要发现集群中能做master的节点数,配置n(es节点的个数)/2防止脑裂,选举在机器大于3的时候。
path.data: /data/elasticsearch
path.logs: /usr/local/ELK/elasticsearch/logs
discovery.zen.minimum_master_nodes: 2
http.cors.enabled: true
http.cors.allow-origin: "*"
复制整个文件夹再次修改文件
cluster.name: my-es
node.name: node-2
node.master: true
node.data: true
http.port: 8200
transport.tcp.port: 8300
network.host: 0.0.0.0
discovery.zen.ping.unicast.hosts: ["127.0.0.1", "127.0.0.1:8300"]
node.max_local_storage_nodes: 2
#discovery.zen.ping_timeout: 30s #设置超时时间,一般来说网络不是很稳定的话设置长一点
#discovery.zen.minimum_master_nodes: 2 #至少要发现集群中能做master的节点数,配置n(es节点的个数)/2防止脑裂,选举在机器大于3的时候。
path.data: /data/elasticsearch
path.logs: /usr/local/ELK/elasticsearch/logs
discovery.zen.minimum_master_nodes: 2
http.cors.enabled: true
http.cors.allow-origin: "*"
集成ik
./bin/elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v7.7.0/elasticsearch-analysis-ik-7.7.0.zip
创建索引
{
"settings": {
"number_of_shards": 3,
"number_of_replicas": 1,
"analysis":{
"analyzer":{
"ik":{
"tokenizer":"ik_max_word"
}
}
}
},
"mappings": {
"properties": {
"praise_rate": {"type": "double"},
"discription": {"type":"text","analyzer": "ik_max_word"},
"create_time": {"format": "strict_date_optional_time||epoch_millis","type": "date"},
"level": {"type": "long"},
"author": {"analyzer": "ik_smart", "type": "text"},
"isbn": {"type": "text"},
"language": {"type": "long"},
"type": {"type": "long"},
"is_delete": {"type": "long"},
"reader_number": {"type": "long"},
"imgurl": {"type": "text"},
"recommend_number": {"type": "long"},
"score": {"type": "long"},
"update_time": {"format": "strict_date_optional_time||epoch_millis","type": "date"},
"word_count": {"type": "long"},
"price": {"type": "double"},
"name": {"analyzer": "ik_max_word","type": "text"},
"publishdate": {"format": "strict_date_optional_time||epoch_millis","type": "date"},
"publisher": {"type": "text"},
"id": {"type": "long"},
"state": {"type": "long"},
"page_count": {"type": "long"}
}
}
}
验证
_analyze
{
"analyzer": "ik_smart",
"text": "中国人富强"
}
{
"analyzer": "ik_max_word",
"text": "中国人富强"
}
elasticsearch-sql安装
https://github.com/NLPchina/elasticsearch-sql