elasticsearchlisted
Install: claude install-skill ryukyagamilight/terminal-skills
# Elasticsearch 集群管理
## 概述
Elasticsearch 索引管理、查询 DSL、集群运维等技能。
## 集群管理
### 集群状态
```bash
# 集群健康
curl -X GET "localhost:9200/_cluster/health?pretty"
# 集群状态
curl -X GET "localhost:9200/_cluster/state?pretty"
# 集群统计
curl -X GET "localhost:9200/_cluster/stats?pretty"
# 节点信息
curl -X GET "localhost:9200/_nodes?pretty"
curl -X GET "localhost:9200/_nodes/stats?pretty"
# 分片分配
curl -X GET "localhost:9200/_cat/shards?v"
curl -X GET "localhost:9200/_cat/allocation?v"
```
### Cat API
```bash
# 常用 cat 命令
curl -X GET "localhost:9200/_cat/health?v"
curl -X GET "localhost:9200/_cat/nodes?v"
curl -X GET "localhost:9200/_cat/indices?v"
curl -X GET "localhost:9200/_cat/shards?v"
curl -X GET "localhost:9200/_cat/segments?v"
curl -X GET "localhost:9200/_cat/count?v"
curl -X GET "localhost:9200/_cat/recovery?v"
curl -X GET "localhost:9200/_cat/thread_pool?v"
```
## 索引管理
### 索引操作
```bash
# 创建索引
curl -X PUT "localhost:9200/my_index" -H 'Content-Type: application/json' -d'
{
"settings": {
"number_of_shards": 3,
"number_of_replicas": 1
},
"mappings": {
"properties": {
"title": { "type": "text" },
"content": { "type": "text" },
"timestamp": { "type": "date" },
"status": { "type": "keyword" }
}
}
}'
# 删除索引
curl -X DELETE "localhost:9200/my_index"
# 查看索引
curl -X GET "localhost:9200/my_index?pretty"
curl -X GET "localhost:9200/my_index/_mapping?pretty"
curl -X GET "localhost:9200/my_index/_settings?pretty"
# 索引别名
curl -X POST "localhost:9200/_alias