[英]What's the difference between cloning and reindexing an index in Elasticsearch?
For example:例如:
When is each API best for what?每个 API 什么时候最适合什么?
你有答案:“Reindex 不会从源索引复制设置。映射、分片计数、副本等必须提前配置。”
Clone and ReIndex performs similar operations in Elasticsearch, but it has fundamentally some differences. Clone 和 ReIndex 在 Elasticsearch 中执行类似的操作,但本质上还是有一些区别的。
What is a Clone operation ?什么是克隆操作?
Clone operation will clone an existing index into a new index, where each original primary shard is cloned into a new primary shard in the new index.克隆操作会将现有索引克隆到新索引中,其中每个原始主分片都被克隆到新索引中的新主分片中。 Basically this functionality is to copy an existing index to a new index with the same properties and settings as that of the original index.
基本上,此功能是将现有索引复制到具有与原始索引相同的属性和设置的新索引。
The following are the internal activities happening as part of the clone operation.以下是作为克隆操作的一部分发生的内部活动。
Clone functionality is useful in cases where we need the a copy of the index as is to another index.克隆功能在我们需要将索引原样复制到另一个索引的情况下很有用。 Clone will maintain the same number of shards, same mapping and settings as that of the source index in the target index.
Clone 将在目标索引中维护与源索引相同的分片数、相同的映射和设置。
What is a ReIndex operation ?什么是 ReIndex 操作?
ReIndex operation copies the contents of a source index and writes it to a target index. ReIndex操作复制源索引的内容并将其写入目标索引。 This operation copies only the data and does not copies the index settings.
此操作仅复制数据,不复制索引设置。 We need to create the target index upfront with the required settings and mapping before doing the reindex operation.
在执行重新索引操作之前,我们需要使用所需的设置和映射预先创建目标索引。 The source and destination can be any pre-existing index, index alias, or data stream.
源和目标可以是任何预先存在的索引、索引别名或数据流。 However, the source and destination must be different.
但是,源和目标必须不同。 ReIndex is suitable for cases that requires updating the number of shards, updating the mapping, updating the settings etc. I usually perform reindex to update the mapping.
ReIndex 适用于需要更新分片数量、更新映射、更新设置等的情况。我通常执行 reindex 来更新映射。
ReIndex operation can be performed in the background by setting the following property可以通过设置以下属性在后台进行ReIndex操作
wait_for_completion=false.
Sample API request for clone operation:克隆操作的示例 API 请求:
POST /my_source_index/_clone/my_target_index
Sample API request for reindex operation:重新索引操作的示例 API 请求:
POST _reindex
{
"source": {
"index": "source_index"
},
"dest": {
"index": "target_index"
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.