Elasticsearch经常使用API总结

一、查看集群设置nginx

GET /_cluster/settings

二、设置allocationjson

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

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

三、删除索引app

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

四、查看未分配分片(unassigned shard)curl

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

五、查看索引url

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

六、查看模板(template)spa

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

七、删除模板code

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

八、加载模板blog

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

九、查看mapping索引

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

十、查看集群的状态文档

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

十一、计算集群中文档数量

curl -u elastic:changeme 'http://10.80.17.154:9200/_count?pretty' -d '{"query": {"match_all": {}}}'
相关文章
相关标签/搜索