目录

Elasticsearch常用API操作

如果有Kibana的话,以下所有操作都可以在Kibana的DevTools页面进行调试,可以免去认证操作。

/images/20220425224238.png

查看所有索引

curl -u elastic:xlFnyMMyZiqjkzLIV5Kd -s 192.168.13.127:9200/_cat/indices?v

删除索引

curl -u elastic:xlFnyMMyZiqjkzLIV5Kd -s -XDELETE 192.168.13.127:9200/索引名字

索引名字可以通过查看索引接口查看

修改密码

curl -H "Content-Type:application/json" -XPOST -u elastic:xlFnyMMyZiqjkzLIV5Kd 'http://127.0.0.1:9200/_xpack/security/user/elastic/_password' -d '{ "password" : "123456" }'

添加角色

curl -XPOST -H 'Content-type: application/json' -u elastic:xlFnyMMyZiqjkzLIV5Kd 'http://10.163.19.231:9600/_xpack/security/role/admin?pretty' -d '{
"run_as":["elastic"],
"cluster":["all"],
"indices":[
 {
  "names":["*"],
  "privileges":["all"]
 }
]
}'

查看角色

curl -XGET -H 'Content-type: application/json' -u elastic:xlFnyMMyZiqjkzLIV5Kd 'http://10.163.19.231:9600/_xpack/security/role/admin?pretty'