1 创建索引
(1)简单方式
PUT study
#! Deprecation: the default number of shards will change from [5] to [1] in 7.0.0; if you wish to continue using the default of [5] shards, you must manage this on the create index request or with an index template
{
"acknowledged": true,
"shards_acknowledged": true,
"index": "study"
}
备注:索引名不能包含大些字母
(2)指定参数
PUT learn
{
"settings": {
"number_of_shards": 3,
"number_of_replicas": 1
}
}
2 查看索引
(1)查看指定索引的配置信息
GET /learn/_settings
{
"learn": {
"settings": {
"index": {
"creation_date": "1539313402808",
"number_of_shards": "3",
"number_of_replicas": "1",
"uuid": "uJaeq_ttTLKArUZNwefGeg",
"version": {
"created": "6040299"
},
"provided_name": "learn"
}
}
}
}
(2)查看多个索引
GET /learn,study/_settings
3 删除索引
DELETE test
{
"acknowledged": true
}
4 索引的打开与关闭
(1)关闭索引
POST /learn/_close
(2)尝试插入数据
PUT /learn/article/1
{
"title":"kibana"
}
{
"error": {
"root_cause": [
{
"type": "index_closed_exception",
"reason": "closed",
"index_uuid": "uJaeq_ttTLKArUZNwefGeg",
"index": "learn"
}
],
"type": "index_closed_exception",
"reason": "closed",
"index_uuid": "uJaeq_ttTLKArUZNwefGeg",
"index": "learn"
},
"status": 400
}
(3)重新打开索引
POST /learn/_open
{
"acknowledged": true,
"shards_acknowledged": true
}