ElasticSearch 学习笔记 - 4. 索引

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
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值