获取所有_cat系列的操作
curl http://localhost:9200/_cat
=^.^=
/_cat/allocation
/_cat/shards
/_cat/shards/{index}
/_cat/master
/_cat/nodes
/_cat/tasks
/_cat/indices
/_cat/indices/{index}
/_cat/segments
/_cat/segments/{index}
/_cat/count
/_cat/count/{index}
/_cat/recovery
/_cat/recovery/{index}
/_cat/health
/_cat/pending_tasks
/_cat/aliases
/_cat/aliases/{alias}
/_cat/thread_pool
/_cat/thread_pool/{thread_pools}
/_cat/plugins
/_cat/fielddata
/_cat/fielddata/{fields}
/_cat/nodeattrs
/_cat/repositories
/_cat/snapshots/{repository}
/_cat/templates
可以后面加一个v,让输出内容表格显示表头; pretty则让输出缩进更规范
集群状态
curl -X GET "localhost:9200/_cluster/health?pretty"
节点状态
curl -X GET "localhost:9200/_cat/nodes?pretty&v"
分片状态
curl -X GET "localhost:9200/_cat/shards?v&pretty"
#分片中如果存在未分配的分片, 可以查看未分片的原因:_cat/shards?h=index,shard,prirep,state,unassigned.reason&v
索引管理
curl -X GET "localhost:9200/_cat/indices?v"
#条件过滤:_cat/indices?v&health=yellow
#排序:_cat/indices?v&health=yellow&s=docs.count:desc
索引详细信息
curl -X GET "localhost:9200/chat_index_alias/_stats?pretty"
curl -X GET "localhost:9200/_cat/count/chat_index_alias?v&pretty"
新建索引
curl -X PUT "localhost:9200/my_index_name" -d '
{
"settings" : {
"index" : {
"number_of_shards" : 3,
"number_of_replicas" : 2
}
}
}'
删除索引
curl -X DELETE "localhost:9200/index_name"
索引查询
#分词搜索
curl -X POST "localhost:9200/chat_index_alias/_search" -d '
{
"query": {
"match": {
"question": "吃饭了吗"
}
}
}'
#完全匹配搜索
curl -X POST "localhost:9200/chat_index_alias/_search" -d '
{
"query": {
"match_phrase": {
"question": "你吃饭了"
}
}
}'
别名
#查看别名
curl -X GET "localhost:9200/_alias/chat_index_alias?pretty"
#增加别名
curl -X PUT "localhost:9200/my_index/_alias/my_index_alias?pretty"
#删除别名(一般纯删除别名使用的比较少,一般是别名重新绑定(删除和绑定为一个原子操作)
curl -X POST 'http://localhost:9200/_aliases' -d '
{
"actions": [
{"remove": {"index": "my_index", "alias": "my_index_alias"}}
]
}'
#别名重新绑定
curl -XPOST 'http://localhost:9200/_aliases' -d '
{
"actions" : [
{ "remove" : { "index" : "my_index", "alias" : "my_index_alias" } },
{ "add" : { "index" : "my_index_v2", "alias" : "my_index_alias" } }
]
}'
文档更新时间: 2021-05-19 11:11 作者:张尚