PUT /twitter
指定索引分片、副本集:
PUT /twitter
{
"settings" : {
"index" : {
"number_of_shards" : 3, # 设置分片数量
"number_of_replicas" : 2 # 设置副本集数量
}
}
}
# 等同于:
PUT /twitter
{
"settings" : {
"number_of_shards" : 3,
"number_of_replicas" : 2
}
}
指定索引映射:
PUT /test
{
"settings" : {
"number_of_shards" : 1
},
"mappings" : {
"properties" : {
"field1" : { "type" : "text" }
}
}
}
指定别名,alias 别名类似视图的概念,是对索引字段的一个逻辑视图:
PUT /test
{
"aliases" : {
"alias_1" : {},
"alias_2" : {
"filter" : {
"term" : {"user" : "kimchy" }
},
"routing" : "kimchy"
}
}
}
DELETE /twitter
# 获取索引
GET /twitter
# 查看索引是否存在
HEAD /twitter
被关闭的索引会被被禁止所有读写操作。
# 关闭索引
POST /twitter/_close
# 开启索引
POST /twitter/_open