一、使用docker安装单节点elasticsearch
1.新建elasticsearch.yml
cluster.name: "docker-cluster"
network.host: 0.0.0.0
# 配置远程访问
http.host: 0.0.0.0
# 因为elasticsearch与elasticsearch-head工具是前后端分离项目,所以需要处理跨域问题
http.cors.enabled: true
http.cors.allow-origin: "*"
# # 开启账户密码验证
# http.cors.allow-headers: Authorization,X-Requested-With,Content-Length,Content-Type
# xpack.security.enabled: true
# xpack.security.transport.ssl.enabled: true.
.
2.执行docker安装命令
docker run --name elasticsearch7 \
--restart=always \
-e "discovery.type=single-node" \
-v /home/docker/elasticsearch7/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml \
-p 19200:9200 -p 19300:9300 \
-d elasticsearch:7.16.1注意:执行命令时需要更改自己的elasticsearch.yml文件路径,和需要对位提供的端口
.
.
二、使用Windows自带的edge浏览器安装ES插件,并加入链接信息
使用edge浏览器打开(es-client - Microsoft Edge Addons)(推荐用这个插件,使用其他的也可以)
点击右上角“获取”按钮安装此插件
打开插件添加elasticsearch信息(忽略这一步的讲解)
.
.
.
.
三、RESTful请求方式说明
HEAD 只获取某个资源的头部信息
GET 获取资源
POST 创建或更新资源
PUT 创建或更新资源
DELETE 删除资源
.
.
.
.
四、使用RESTful对索引的基础操作
1.使用RESTful-获取当前elasticsearch信息
GET /{
"name" : "show-data-1",
"cluster_name" : "showdata",
"cluster_uuid" : "bOWzxkB8QkC7nrHCTtV9Vg",
"version" : {
"number" : "7.2.0",
"build_flavor" : "default",
"build_type" : "docker",
"build_hash" : "508c38a",
"build_date" : "2019-06-20T15:54:18.811730Z",
"build_snapshot" : false,
"lucene_version" : "8.0.0",
"minimum_wire_compatibility_version" : "6.8.0",
"minimum_index_compatibility_version" : "6.0.0-beta1"
},
"tagline" : "You Know, for Search"
}
2.使用RESTful-创建一个索引(student)
PUT /student{
"acknowledged" : true,
"shards_acknowledged" : true,
"index" : "student"
}
3.使用RESTful-查询一个索引信息(student)
GET /student{
"student" : {
"aliases" : { },
"mappings" : { },
"settings" : {
"index" : {
"creation_date" : "1688533040653",
"number_of_shards" : "1",
"number_of_replicas" : "1",
"uuid" : "LWWGSmoGTUG4r-pY8tE0ZA",
"version" : {
"created" : "7020099"
},
"provided_name" : "student"
}
}
}
}
4.使用RESTful-删除一个索引信息(student)
DELETE /student{
"acknowledged" : true
}
4.使用RESTful-关闭一个索引信息(student)
POST /student/_close{
"acknowledged" : true,
"shards_acknowledged" : true
}
5.使用RESTful-打开一个索引信息(student)
POST /student/_open{
"acknowledged" : true,
"shards_acknowledged" : true
}
-