Elasticsearch Api 操作
Elasticsearch api 操作
常用选项
- 返回漂亮的展示
?pretty=true
- 返回人性化的结果
?human
cat apis
查看节点版本信息
curl -s -XGET -u elastic:elastic http://127.0.0.1:9200
查看集群健康状态
curl -u elastic:elastic http://127.0.0.1:9200/_cat/health?v
查看nodes状态
curl -u elastic:elastic http://127.0.0.1:9200/_cat/nodes?pretty
查看所有索引
curl -s -XGET -u elastic:elastic http://127.0.0.1:9200/_cat/indices
# 添加过滤条件
curl -u elastic:elastic http://127.0.0.1:9200/_cat/indices/tbex*-2020.09.25?v
查看全部索引分片信息
curl -s -XGET -u elastic:elastic http://127.0.0.1:9200/_cat/shards?v
看服务堆积
curl -s -XGET -u elastic:elastic http://127.0.0.1:9200/_cat/thread_pool?v
cluster apis
查看集群健康状态
curl -u elastic:elastic http://127.0.0.1:9200/_cluster/health?pretty
返回待处理的集群任务
curl -s -XGET -u elastic:elastic http://127.0.0.1:9200/_cluster/pending_tasks
delete apis
删除某一天的索引
curl -XDELETE -u elastic:elastic "http://127.0.0.1:9200/*-2020.09.22"
删除指定索引
curl -XDELETE -u elastic:elastic "http://127.0.0.1:9200/testindex-2020.01.02"
提高分片恢复的速度
curl -X POST "http://127.0.0.1:9200/_flush/synced?pretty"
创建或更新role_mappings
POST /_security/role_mapping/mapping1
{
"roles": [ "user"],
"enabled": true,
"rules": {
"field" : { "username" : "*" }
},
"metadata" : {
"version" : 1
}
}
获取表结构
curl -s -XGET -u elastic:elastic http://127.0.0.1:9200/exchange-2020.04.14/_mapping?pretty
创建默认结构表
curl -s -u elastic:elastic -XPUT 'http://127.0.0.1:9200/index-2020.04.15'
创建指定结构的表
curl -s -u elastic:elastic -XPUT 'http://127.0.0.1:9200/index-service-2020.04.15' -H "Content-Type: application/json" -d @3.txt
查看单个索引配置
curl -s -XGET -u elastic:elastic http://127.0.0.1:9200/vpclog-2020.05.12/_settings
未处理数据(等待中的队列)
curl -s -XGET -u elastic:elastic http://127.0.0.1:9200/_cluster/pending_tasks
查看索引
curl -u elastic:elastic http://127.0.0.1:9200/_cat/indices/index*-2020.09.25?v