ES 创建索引设置(setting)基础
1.创建索引
PUT /my_index { "settings": { ... any settings ... }, "mappings": { "type_one": { ... any mappings ... }, "type_two": { ... any mappings ... }, ... } }
如果你想禁止自动创建索引,你 可以通过在
config/elasticsearch.yml
的每个节点下添加下面的配置:
action.auto_create_index: false
2.索引设置
索引设置分为static 和dynamic,
static详见:
修改分片和副本数:PUT /my_index { "number_of_replicas":0, "number_of_shards":1 }
动态设置:
PUT /my_index/_settings { "index" : { "number_of_replicas":0 } }
2.1 创建my_index 索引
使用默认配置:
查看该索引的设置: 5个分片,一个副本
GET /my_index/_settings { "my_index": { "settings": { "index": { "creation_date": "1507996404894", "number_of_shards": "5", "number_of_replicas": "1", "uuid": "q3xU7mMKTUKmqEq4FUsswA", "version": { "created": "5050199" }, "provided_name": "my_index" } } } }head 查看如下:
修改副本数量:(分片数不能动态修改)
PUT /my_index/_settings { "number_of_replicas":0 } ---------------------- { "acknowledged": true }
副本删除了:
一次修改所有的索引副本数量:(强迫症,自己的虚拟机本来是2个节点的集群的,但每次只启动一台,所以建索引都是按照默认2个副本,不想你改配置,所以,又不想再head 上看到黄色的标识!!用下面全部修改下,线上环境慎用!)
PUT /_all/_settings { "index": {"number_of_replicas":0} }