elasticserch常用命令api
集群
curl -XGET 'localhost:9200/_cluster/health?pretty=true' 集群健康
curl -XGET 'localhost:9200/_cluster/settings?pretty=true' 集群设置
curl -XGET 'localhost:9200/_cluster/health?level=indices&pretty=true' 集群健康-列出索引
curl -XPUT 'localhost:9200/_cluster/settings' -H 'Content-Type:application/json' -d '{"transient":{"cluster":{"max_shards_per_node":4000}}}'
curl -XPUT 'localhost:9200/_cluster/settings' -H 'Content-Type:application/json' -d '{"persisent":{"cluster":{"max_shards_per_node":4000}}}' 更新集群setting 分片上限
分片
curl -XGET 'localhost:9200/_cluster/allocation/explain?pretty' 未分片详情
curl -XGET 'localhost:9200/_cat/shards?v' 索引分片详情列表
curl -XGET 'localhost:9200/_cat/shards?h=index,shard,prirep,state,unassigned.reason' 索引分片列表指定字段
curl -XGET 'localhost:9200/_cat/allocation?v' 集群分片详情
索引
curl -XGET 'localhost:9200/_cat/indices?v' 查看索引列表
curl -XGET 'localhost:9200/_cat/indices?index=*2020.0707*' 模糊查询索引列表
curl -XGET 'localhost:9200/.kibana_1/setting' 查看索引配置
curl -XDELETE 'localhost:9200/index_name' 删除
curl -XGET 'localhost:9200/_cluster/health/index_name?pretty' 索引健康
curl -XGET 'localhost:9200/_cat/segments/index_name?v' 索引segments
curl -XPUT 'localhost:9200/index_name/_settings' -H 'Content-Type:application/json' -d '{"number_of_replicas":0}' 更新索引setting设置
curl -XPUT 'localhost:9200/index_name' -H 'Content-Type:application/json' -d '{"setting":{"number_of_shards":1,"number_of_replicas":1}}' 新建索引-指定主从分片数
curl -XPUT 'localhost:9200/index_name/_doc/1' -H 'Content-Type:application/json' -d '{"id":1001}' 索引下新建文档
curl -XGET 'localhost:9200/index_name/_search?size=10' 查询10条索引
curl -XGET 'localhost:9200/index_name/_search?size=10&pretty' -H 'Content-Type:application/json' -d '{"query":{"term":{"id":"1001"}}}' term 精确匹配查询
curl -XGET 'localhost:9200/index_name/_search?size=10&pretty' -H 'Content-Type:application/json' -d '{"query":{"match":{"id":"1001"}}}' match 分词匹配查询
curl -XGET 'localhost:9200/index_name/_search?size=10&pretty&q=id:1001' url传参查询
curl -XGET 'localhost:9200/index_name/index_name/1001?pretty' /_index/_type/_id 查询索引详情
线程池
curl -XGET 'localhost:9200/_cat/thread_pool/write?v' 线程池信息
curl -XGET 'localhost:9200/_nodes/stats/pretty' > 1.txt 节点详情(有线程池信息)
快照
curl -XPUT 'localhost:9200/_snapshot/es_backup' -H 'Content-Type:application/json' -d '{"type":"fs","setting":{"location":"/data/es_backup","compress":true}}' 创建仓库
curl -XPUT 'localhost:9200/_snapshot/es_backup/snapshot_all' 备份所有-增量
curl -XPUT 'localhost:9200/_snapshot/es_backup/snapshot_001' -d '{"indices":"index_name"}' -H 'Content-Type:application/json' 备份指定索引
curl -XGET 'localhost:9200/_snapshot/es_backup/_all' 查询所有快照
curl -XGET 'localhost:9200/_snapshot/es_backup/snapshot_001/_status' 查询某快照状态
curl -XDELETE 'localhost:9200/_snapshot/es_backup/snapshot_001' 删除快照
curl -XPOST 'localhost:9200/_snapshot/es_back/snapshot_001/_restore' 恢复
浙公网安备 33010602011771号