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

 

 

  

 

posted @ 2018-07-12 10:18  努力的菜花  阅读(267)  评论(0编辑  收藏  举报