Elasticsearch Index Management 索引管理
Elasticsearch search scroll 游标查询,内容来自 B 站中华石杉 Elasticsearch 顶尖高手系列课程核心知识篇,英文内容来自 Elasticsearch: The Definitive Guide [2.x]
为什么要手动创建索引?
... you start wanting to fine-tune the indexing and search process to better suit your particular use case.
虽然 Elasticsearch 默认的动态索引可以很方便的使用,但是如果你希望根据业务需求对索引和查询的过程进行调优,那么就需要考虑进行索引管理。
创建索引 Creating an Index
... want to ensure that the index has been created with the appropriate number of primary shards, and that analyzers and mappings are set up before we index any data.
创建索引的语法
number_of_shards: The number of primary shards, this setting cannot be changed after index creation.
number_of_replicas: The number of replica shards (copies) that each primary shard should have. This setting can be changed at any time on a live index.
可以在配置文件 config/elasticsearch.yml
中禁止自动创建索引:
创建索引的示例
修改索引
删除索引 Deleting an Index
To delete an index:
Delete multiple indices:
Delete all indices
为了防止“删除跑路”,eliminate the possibility an accidental mass-deletion,可以在配置文件 elasticsearch.yml
中设置:
禁用 _all 和 通配符,避免误删。
版权声明: 本文为 InfoQ 作者【escray】的原创文章。
原文链接:【http://xie.infoq.cn/article/2b84cf8f112cb9c12ebb8f612】。
本文遵守【CC-BY 4.0】协议,转载请保留原文出处及本版权声明。
评论