簡體   English   中英

Elasticsearch 並行批量更新或索引優先

[英]Elasticsearch parallel bulk update or index first

所以在我的項目中,我使用 Elasticsearch 的並行批量幫助程序 function 添加批量更新 function。 這是我的更新 function 的樣子:

action = {
  "_id": id,
  "_op_type": "update",
  "_index": some_index,
  "doc": {'some_key': 'some_value'}
}
ACTIONS.append(action)

# run the bulk operations
for success, info in parallel_bulk(self.es, ACTIONS, index=some_index):

我有一個索引 function 如下所示:

action = {
  "_id": id,
  "_op_type": "index",
  "_source": payloads[id],
}
ACTIONS.append(action)

# run the bulk operations
for success, info in parallel_bulk(self.es, ACTIONS, index=some_index):

我的問題是,我應該首先使用更新 function (意味着將 doc 字段添加到每條記錄)還是首先索引所有記錄? 似乎雙向都可以,但我想知道是否應該以另一種方式來。

謝謝!

index命令應該首先創建文檔的第一個版本,然后您可以使用update命令更新您的文檔。

當您想要做的只是部分update某些文檔,即只有幾個字段時,應該考慮更新。

如果你想用新版本覆蓋整個文檔,應該考慮index 此操作也比update更快,因為它不需要先檢索文檔的現有版本、更新它、刪除舊版本並重新索引新版本。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM