索引管理
查看索引
查看所有索引
curl 192.168.1.27:9200/_cat/indices?v查看单个索引
curl 192.168.1.27:9200/<index-name>创建索引
创建默认索引
curl -X PUT 192.168.1.27:9200/<index-name>创建指定索引(指定索引分片数为3 副本数为1)
curl -X PUT 192.168.1.27:9200/<index-name> \
-H "Content-Type: application/json" \
-d '{
"settings": {
"number_of_shards": 3,
"number_of_replicas": 1
}
}'修改索引
修改索引副本数
curl -X PUT 192.168.1.27:9200/<index-name>/_settings \
-H "Content-Type: application/json" \
-d '{
"settings": {
"number_of_replicas": 2
}
}'删除索引
删除单个索引
curl -X DELETE 192.168.1.27:9200/<index-name>删除多个索引
curl -X DELETE 192.168.1.27:9200/<index-name>*查看索引别名
curl 192.168.1.27:9200/_aliasescurl -s 192.168.1.27:9200/_aliases | jq索引添加别名
给单个索引添加别名
curl -X POST 192.168.1.27:9200/_aliases \
-H "Content-Type: application/json" \
-d '{
"actions": [
{
"add": {
"index": "study-3shards-1replicas",
"alias": "study-3-1"
}
}
]
}'给多个索引添加别名
curl -X POST 192.168.1.27:9200/_aliases \
-H "Content-Type: application/json" \
-d '
{
"actions": [
{
"add": {
"index": "study-3shards-1replicas",
"alias": "study-3-1"
}
},
{
"add": {
"index": "study-3shards-2replicas",
"alias": "study-3-2"
}
}
]
}'删除索引别名
删除单个索引别名
curl -X POST 192.168.1.27:9200/_aliases \
-H "Content-Type: application/json" \
-d '{
"actions": [
{
"remove": {
"index": "study-3shards-1replicas",
"alias": "study-3-1"
}
}
]
}'删除多个索引别名
curl -X POST 192.168.1.27:9200/_aliases \
-H "Content-Type: application/json" \
-d '
{
"actions": [
{
"remove": {
"index": "study-3shards-1replicas",
"alias": "study-3-1"
}
},
{
"remove": {
"index": "study-3shards-2replicas",
"alias": "study-3-2"
}
}
]
}'关闭索引
curl -X POST 192.168.1.27:9200/<index-name>/_close打开索引
curl -X POST 192.168.1.27:9200/<index-name>/_openLast updated