创建索引
PUT /my_index
{
"settings": { ... any settings ... },
"mappings": {
"type_one": { ... any mappings ... },
"type_two": { ... any mappings ... },
...
}
}
如果你想禁止自动创建索引,你 可以通过在 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
。对于活动的索引库,这个配置可以随时修改。
PUT /my_temp_index
{
"settings": {
"number_of_shards" : 1,
"number_of_replicas" : 0
}
}
用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