-
Type:
Task
-
Resolution: Unresolved
-
Priority:
Major - P3
-
None
-
Affects Version/s: None
-
Component/s: None
-
None
-
Cluster Scalability
-
None
-
None
-
None
-
None
-
None
-
None
-
None
Pipeline should look like:
[
{
// only if resuming
$match: {
$expr: {$gte: ["$_id", {$literal: <last seen _id>}]}}
}
},
{
$sort: {_id: 1}
},
{
// Use replaceRoot to guarantee the order of output fields.
$repacleRoot: {
newRoot: {
_id: {
$indexKey: {doc: "$$ROOT", spec: <object containing global index spec>}
},
documentKey: {
// Use arrayToObject as a work around to output valid shard key patterns with
// dotted field names.
$arrayToObject: [[
{k: "_id", v: "$_id"},
// Explicitly output null value for missing fields, otherwise $arrayToObject complains:
// "$arrayToObject requires an object keys of 'k' and 'v'. Found incorrect number of keys:1"
{k: <sourceShardKey1>, v: {$ifNull: ["$sourceShardKey1", null]}},
…
]]
}
}
},
{
// unwind is needed because $indexKey outputs an array to handle multikey
$unwind: "$_id"
},
{
$project: {
_id: 0,
shard: {
$owningShard: {shardKeyVal: {_id: "$_id"}, ns: <globalIndexNs>, uuid: <globalIndexUUID>},
},
indexData: "$$ROOT"
}
},
{
$match: {shard: <recipientShardId>}
},
{
$replaceRoot: {
newRoot: "$indexData"
}
}
]
- depends on
-
SERVER-68685 Add new $_internalIndexKey agg expression
-
- Closed
-
-
SERVER-68686 Add new $_internalOwningShard agg expression
-
- Closed
-