Elasticsearch常用API总结

1、查看集群设置

GET /_cluster/settings

2、设置allocation

#禁止分片分配
put _cluster/settings
{
"transient":{
"cluster.routing.allocation.enable": "none"
}
}
#允许分片分配

put /_cluster/settings
{
"transient":{
"cluster.routing.allocation.enable": "all"
}
}

3、删除索引

# kibana dev tools
delete {index_name}
eg:delete ngxrelate-2018_05_26
# curl方式
curl -XDELETE -u elastic:changeme  'localhost:9200/nginxaccess-2017_09?pretty'

4、查看未分配分片(unassigned shard)

# curl方式
curl  http://10.80.17.154:9200/_cat/shards | grep -i unassigned

5、查看索引

# kibana dev tools
GET /_cat/indices?v
# curl 方式
curl -u elastic:changeme 'http://localhost:9200/_cat/indices?v'

6、查看模板(template)

# kibana dev tools
GET /_template/nginxaccess?pretty
# curl方式
curl -u elastic:changeme 'http://localhost:9200/_template/nginxaccess?pretty'

7、删除模板

# kibana dev tools
DELETE /_template/nginxaccess
# curl方式
curl -XDELETE -u elastic:changeme 'http://localhost:9200/_template/nginxaccess'

8、加载模板

curl -u elastic:changeme -XPUT 'http://localhost:9200/_template/nginxaccess' -d @nginxaccess.json 

9、查看mapping

curl -u elastic:changeme 'http://localhost:9200/{INDEX_NAME}/_mapping/?pretty'

10、查看集群的状态

# kibana dev tools
GET /_cat/health?v&ts=false&pretty
# curl 
curl -u elastic:changeme 'http://localhost:9200/_cat/health?v&ts=false&pretty'

11、计算集群中文档数量

curl -u elastic:changeme 'http://10.80.17.154:9200/_count?pretty' -d '{"query": {"match_all": {}}}'

 

 

  

 

转载于:https://www.cnblogs.com/sailq21/p/9298109.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值