美文网首页
elasticsearch 索引管理

elasticsearch 索引管理

作者: 蜗牛ICU | 来源:发表于2019-03-30 00:09 被阅读0次

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、删除索引:

    使用以下的请求来删除索引:
    DELETE /my_index
    你也可以用下面的方式删除多个索引
    DELETE /index_one,index_two
    DELETE /index_*
    你甚至可以删除所有索引
    DELETE /_all

3、索引的基本配置:

number_of_shards:
    分片数,默认 5 
    
number_of_replicas
每个主分片的复制分片个数,默认是 5。
这个配置可以随时在活跃的索引上修改。

需求:
    创建一个主分片,没有复制片的小索引。
PUT /my_temp_index
{
    "settings": {
        "number_of_shards" :   1,
        "number_of_replicas" : 0
    }
}

更改分片数量:
    PUT /my_temp_index/_settings
    {
        "number_of_replicas": 1
    }

相关文章

网友评论

      本文标题:elasticsearch 索引管理

      本文链接:https://www.haomeiwen.com/subject/ggvdbqtx.html