索引的CURD

创建索引

基本语法:

PUT /my_index
{
    "settings": { ... any settings ... },
    "mappings": {
        "type_one": { ... any mappings ... },
        "type_two": { ... any mappings ... },
        ...
    }
}

示例

示例

PUT /my_index
{
  "settings": {
    "number_of_shards": 1,
    "number_of_replicas": 0
  },
  "mappings": {
    "my_type": {
      "properties": {
        "my_field": {
          "type": "text"
        }
      }
    }
  }
}

修改索引

number_of_shards 不能被修改。

删除索引

由于DELETE /_all操作的危险性,修改配置禁止这样操作,必须指定索引的名字

查看索引

Last updated

Was this helpful?