yum install -y java-1.8.0-openjdk
vim /etc/security/limits.conf
# 添加
* soft nofile 65536
* hard nofile 65536
# 保存,并重新登陆
vim /etc/sysctl.conf
# 最后一行添加
vm.max_map_count=262144
# 保存
sysctl -p
tar -xvzf elasticsearch-8.0.0-linux-x86_64.tar.gz
# 修改配置
cd elasticsearch-8.0.0
vim config/elasticsearch.yml
# 设置network.host的IP为0.0.0.0
# 设置node.name: node-1
# 设置cluster.initial_master_nodes: ["node-1"]
# 添加
xpack.reporting.encryptionKey: "chenqionghe"
xpack.security.encryptionKey: "122333444455555666666777777788888888"
xpack.encryptedSavedObjects.encryptionKey: "122333444455555666666777777788888888"
# 保存
# 启动
cd bin
./elasticsearch
✅ Elasticsearch security features have been automatically configured!
✅ Authentication is enabled and cluster connections are encrypted.
ℹ️ Password for the elastic user (reset with `bin/elasticsearch-reset-password -u elastic`):
密码
{
"name" : "node-1",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "err8U3ufRS-EiKUqWTh4wQ",
"version" : {
"number" : "8.0.0",
"build_flavor" : "default",
"build_type" : "tar",
"build_hash" : "1b6a7ece17463df5ff54a3e1302d825889aa1161",
"build_date" : "2022-02-03T16:47:57.507843096Z",
"build_snapshot" : false,
"lucene_version" : "9.0.0",
"minimum_wire_compatibility_version" : "7.17.0",
"minimum_index_compatibility_version" : "7.0.0"
},
"tagline" : "You Know, for Search"
}
tar -xvzf kibana-8.0.0-linux-x86_64.tar.gz
vim kibana-8.0.0/config/kibana.yml
# 修改server.host: "0.0.0.0"
# 修改中文 i18n.locale: "zh-CN"
# 修改 server.publicBaseUrl: "http://localhost:5601/"
# 保存
cd kibana-8.0.0/bin/
# 启动
./kibana
cd elasticsearch-8.0.0/bin/
./elasticsearch-reset-password --username kibana_system
y
unzip -d ik-analyzer elasticsearch-analysis-ik-8.0.0.zip
# 注 number_of_shards:分片数
# number_of_replicas:备份数
PUT 索引名
{
"settings": {
"index": {
"number_of_shards": "5",
"number_of_replicas": "1"
}
}
}
PUT blog1
{
"mappings":{
"properties":{
"id":{
"type":"long",
"store":true
},
"title":{
"type":"text",
"store":true,
"index":true,
"analyzer":"standard"
},
"content":{
"type":"text",
"store":true,
"index":true,
"analyzer":"standard"
}
}
}
}
GET blog1
# ?v 可以不加
GET _cat/indices?v
POST blog/_mapping
{
"properties":{
"id":{
"type":"long",
"store": true
},
"title":{
"type":"text",
"store":true,
"index": true,
"analyzer":"standard"
},
"content":{
"type":"text",
"store":true,
"index": true,
"analyzer":"standard"
}
}
}
DELETE index-hello
POST blog/_doc/1
{
"id": 1,
"title": "“开启,这些要点提前看",
"content":"讨论哪些问题?一起了解"
}
或者
POST blog/_doc/
{
"id": 100,
"title": "你好",
"content":"我是程序员间3月1日晚空。"
}
DELETE blog/_doc/1
POST blog/_doc/1
{
"id":1,
"title":"你好来了",
"content":"我在这条路上遇到你"
}
GET blog/_doc/1
查询所有
GET blog/_search
term查询
GET blog/_search
{
"query": {
"term": {
"content": "在"
}
}
}
querystring查询
注:在查询时会对字符串进行分词,并进行分别查询
GET blog/_search
{
"query": {
"query_string": {
"default_field": "title",
"query": "可惜"
}
}
}
GET _analyze?pretty
{
"analyzer": "standard",
"text": ["我是程序员"]
}