ElasticSearch 的索引管理

建立索引

PUT /my-index-000001
索引名要求所有为小写,不能使用特殊字符,长度不能超过255字节。

建立索引同时进行配置

PUT /my-index-000001
{
  "settings": {
    "number_of_shards": 5,   // 分片数量,默认1
    "number_of_replicas": 1  // 副本数量,默认1
  }
}

建立索引同时进行映射配置

PUT /test
{
  "settings": {
    "number_of_shards": 1
  },
  "mappings": {
    "properties": {
      "field1": { "type": "text" }
    }
  }
}

删除索引

DELETE /my-index-000001
DELETE /_all
DELETE /*
支持以逗号分隔的列表或通配符表达式。

获取索引

GET /my-index-000001
GET /_all
GET /*

索引是否存在

HEAD /my-index-000001

响应:app

  • 200 全部指定的索引或别名均存在
  • 404 一个或多个指定的索引或别名不存在