简体   繁体   English

在 Elasticsearch 中克隆和重新索引索引有什么区别?

[英]What's the difference between cloning and reindexing an index in Elasticsearch?

For example:例如:

  1. Clone API 克隆API
  2. Reindex API 重新索引 API

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.以下是作为克隆操作的一部分发生的内部活动。

  • First, it creates a new target index with the same definition as the source index.首先,它创建一个与源索引具有相同定义的新目标索引。
  • Then it hard-links segments from the source index into the target index.然后它将源索引中的段硬链接到目标索引中。 (If the file system doesn't support hard-linking, then all segments are copied into the new index, which is a much more time consuming process.) (如果文件系统不支持硬链接,那么所有段都被复制到新索引中,这是一个更耗时的过程。)
  • Finally, it recovers the target index as though it were a closed index which had just been re-opened.最后,它恢复目标索引,就好像它是一个刚刚重新打开的关闭索引。

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.

相关问题 ElasticSearch的重新索引编制API完成后,目标索引的状态是什么? - What is the state of my destination index after ElasticSearch's reindexing api completes? 在弹性搜索中启用:false 和 index:'no' 有什么区别? - What is the difference between enabled : false and index : 'no' in elasticsearch? 在Elasticsearch中为索引重新索引-ELK - Reindexing a index in elasticsearch - ELK elasticsearch:重新索引索引 - elasticsearch: reindexing an index Elasticsearch中的映射和模板之间有什么区别? - What's the difference between mapping and template in Elasticsearch? Elasticsearch中的SpanWithInQuery和SpanContainingQuery有什么区别? - What's the difference between SpanWithInQuery and SpanContainingQuery in Elasticsearch? 在 elasticsearch 中重新索引后,原始索引中的数据会发生什么变化? - What happens to the data in the original index after reindexing in elasticsearch? ElasticSearch-索引模板和索引模式有什么区别 - ElasticSearch - what is the difference between an index template and an index pattern 在创建索引映射后为文档建立索引与在Elasticsearch中直接通过索引创建文档之间有什么区别 - What's a difference between indexing document after creating an index mapping AND creating an document directly with indexing in Elasticsearch elasticsearch插件和elasticsearch模块之间有什么区别? - What's the difference between elasticsearch plugin and elasticsearch module?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM