我正在尝试使用沙发底座上的 UPDATE 查询语句来更新文档。
前任)
更新用户 SET cityIndex
= 1 where Users.city= "NewYork";
数据太多,我想将 3,000 分成 4,000,然后进行 UPDATE。我该如何进行? 有主索引。
最佳答案
vsr 提到的事件函数方法也非常简单(7 行无注释),您可以将它作为一次性工具运行,从 Everything 部署它。请注意,不需要任何索引即可工作。
// To run configure the settings for this Function, UpdateAllCityIndex, as follows:
//
// Version 7.0+
// "Listen to Location"
// bulk.data.yourcollection
// "Eventing Storage"
// rr100.eventing.metadata
// Binding(s)
// 1. "binding type", "alias name...", "bucket.scope.collection", "Access"
// ---------------------------------------------------------------------------
// "bucket alias", "src_col", "bulk.data.Users", "read and write"
//
// Version 6.X
// "Source Bucket"
// yourbucket
// "MetaData Bucket"
// metadata
// Binding(s)
// 1. "binding type", "alias name...", "bucket", "Access"
// ---------------------------------------------------------------------------
// "bucket alias", "src_col", "Users", "read and write"
//
// For more performance set the workers to the number of physical cores
function OnUpdate(doc, meta) {
// only process documents with the city field
if (!doc.city) return;
// only update New York if cityIndex isn't already 1 or does not exist
if ( doc.city === "NewYork" && (!doc.cityIndex || doc.cityIndex !== 1 )) {
doc.cityIndex = 1;
// write back the updated doc via the alias
src_col[meta.id] = doc;
}
}
关于nosql - Couchbase 更新查询划分,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70149707/