首页 > Windows开发 > 详细

Elasticsearch常用API总结

时间:2018-07-12 12:25:07      阅读:210      评论:0      收藏:0      [点我收藏+]

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": {}}}

 

 

  

 

Elasticsearch常用API总结

原文:https://www.cnblogs.com/sailq21/p/9298109.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!