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": {}}}'
相關文章
相關標籤/搜索