Elasticsearch的routing是什么
时间: 2023-12-20 11:01:05 浏览: 40
Elasticsearch的routing是一种将文档路由到指定分片的机制。当索引文档时,Elasticsearch会根据文档的路由值将文档路由到对应的分片中。这样可以确保同一路由值的文档被路由到同一个分片中,从而提高查询效率。一些常见的用例包括:为每个用户的数据创建一个独立的分片,并使用用户ID作为路由键;或根据地理位置信息将文档路由到特定的分片中。
相关问题
elasticsearch如何修改index.routing.allocation.total_shards_per_node
要修改`index.routing.allocation.total_shards_per_node`参数,可以使用以下步骤:
1. 在Elasticsearch中打开控制台或终端,并使用curl命令发送以下请求:
```
curl -XPUT "http://localhost:9200/_cluster/settings" -H 'Content-Type: application/json' -d'
{
"transient" : {
"cluster.routing.allocation.total_shards_per_node" : <number of shards>
}
}'
```
2. 替换`<number of shards>`为你想要的每个节点承载的总分片数。请注意,这个数字必须是正整数,且不能超过节点数的总和。
3. 发送请求后,Elasticsearch将立即应用更改。你可以使用以下命令验证更改是否已应用:
```
curl -XGET "http://localhost:9200/_cluster/settings"
```
4. 在返回的JSON响应中,你应该看到`total_shards_per_node`参数的值已更新为你所设置的值。
请注意,这些更改可能会对Elasticsearch集群的性能产生影响,因此请确保在应用更改之前进行测试。
elasticsearch如何修改索引的index.routing.allocation.total_shards_per_node
要修改现有索引的`index.routing.allocation.total_shards_per_node`参数,可以使用以下步骤:
1. 在Elasticsearch中打开控制台或终端,并使用curl命令发送以下请求:
```
curl -XPUT "http://localhost:9200/<index>/_settings" -H 'Content-Type: application/json' -d'
{
"index.routing.allocation.total_shards_per_node" : <number of shards>
}'
```
2. 替换`<index>`为要更改其参数的索引名称。
3. 替换`<number of shards>`为你想要的每个节点承载的总分片数。请注意,这个数字必须是正整数,且不能超过节点数的总和。
4. 发送请求后,Elasticsearch将立即应用更改。
请注意,这些更改可能会对Elasticsearch索引的性能产生影响,因此请确保在应用更改之前进行测试。
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)