创建索引

  1. PUT /my_index
  2. {
  3. "settings": { ... any settings ... },
  4. "mappings": {
  5. "type_one": { ... any mappings ... },
  6. "type_two": { ... any mappings ... },
  7. ...
  8. }
  9. }

如果你想禁止自动创建索引,你 可以通过在 config/elasticsearch.yml 的每个节点下添加下面的配置:
action.auto_create_index: false

删除索引

DELETE /indexone,index_two
DELETE /index

DELETE /_all
DELETE /

索引设置

number_of_shards每个索引的主分片数,默认值是 5 。这个配置在索引创建后不能修改。
number_of_replicas每个主分片的副本数,默认值是 1 。对于活动的索引库,这个配置可以随时修改。

  1. PUT /my_temp_index
  2. {
  3. "settings": {
  4. "number_of_shards" : 1,
  5. "number_of_replicas" : 0
  6. }
  7. }

update-index-settings API 动态修改副本数:
PUT /my_temp_index/_settings
{
“number_of_replicas”: 1
}

参考:https://www.elastic.co/guide/cn/elasticsearch/guide/current/root-object.html