elasticsearch 索引设置

索引设置

你可以通过很多种方式来自定义索引行为,你可以阅读Index Modules reference documentation,但是:

提示: Elasticsearch 提供了优化好的默认配置。除非你明白这些配置的行为和为什么要这么做,请不要修改这些配置。

下面是两个最重要的设置:

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
}
要永久生效,写入配置文件,然后重启:

index.number_of_shards: 5
index.number_of_replicas: 0

列出索引:

curl 'localhost:9200/_cat/indices?v'

删除索引:

curl -XDELETE '10.0.67.23:9200/adsense-2017.11.22'
 

索引别名:将索引unwel和别名unwel_index联系一起

curl -XPOST 'http://10.0.62.189:9200/_aliases' -d '  
{  
    "actions" : [  
        { "add" : { "index" : "unwel","alias" : "unwel_index" } }  
    ]  
}'  
原文地址:https://www.cnblogs.com/mikeluwen/p/8027649.html