Anda benar, ada beberapa inkonsistensi dalam implementasi oplog MongoDB yang memungkinkan format dokumen untuk setiap op log yang secara teknis tidak memungkinkan dokumen semacam itu untuk ditanyakan.
Bahkan memasukkan entri yang sama tidak dimungkinkan karena memiliki nama bidang $set:
db.tmp2.insert({
"ts" : Timestamp(1450117240, 1),
"h" : NumberLong(2523649590228245285),
"v" : NumberInt(2),
"op" : "u",
"ns" : "test.tmp",
"o2" : {
"_id" : ObjectId("566f069e63d6a355b2c446af")
},
"o" : {
"$set" : {
"b.d" : NumberInt(4)
}
}
})
2015-12-14T10:27:04.616-0800 E QUERY Error: field names cannot start with $ [$set]
at Error (<anonymous>)
at DBCollection._validateForStorage (src/mongo/shell/collection.js:161:19)
at DBCollection._validateForStorage (src/mongo/shell/collection.js:165:18)
at insert (src/mongo/shell/bulk_api.js:646:20)
at DBCollection.insert (src/mongo/shell/collection.js:243:18)
at (shell):1:9 at src/mongo/shell/collection.js:161
dan b.d tidak valid untuk sebuah kunci
db.tmp.update({ a: 1 }, { $set: { 'b.d': 4 } }, { upsert: true })
WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1 })
db.oplog.rs.find()
db.tmp2.insert({
"ts" : Timestamp(1450117240, 1),
"h" : NumberLong(2523649590228245285),
"v" : NumberInt(2),
"op" : "u",
"ns" : "test.tmp",
"o2" : {
"_id" : ObjectId("566f069e63d6a355b2c446af")
},
"o" : {
"set" : {
"b.d" : NumberInt(4)
}
}
})
2015-12-14T10:23:26.491-0800 E QUERY Error: can't have . in field names [b.d]
at Error (<anonymous>)
at DBCollection._validateForStorage (src/mongo/shell/collection.js:157:19)
at DBCollection._validateForStorage (src/mongo/shell/collection.js:165:18)
at DBCollection._validateForStorage (src/mongo/shell/collection.js:165:18)
at insert (src/mongo/shell/bulk_api.js:646:20)
at DBCollection.insert (src/mongo/shell/collection.js:243:18)
at (shell):1:9 at src/mongo/shell/collection.js:157
Mungkin masalah Jira harus dicatat yang merekomendasikan sintaks dengan pencarian $set harus ditetapkan sebagai nilai:
{
"ts" : Timestamp(1450117240, 1),
"h" : NumberLong(2523649590228245285),
"v" : NumberInt(2),
"op" : "u",
"ns" : "test.tmp",
"o2" : {
"_id" : ObjectId("566f069e63d6a355b2c446af")
},
"o" : {
"$set" : {
"key" : "b.d"
"value" : NumberInt(4)
}
}
}
Pembaruan:Membuat masalah Jira untuk ini:
https://jira.mongodb.org/browse/SERVER-21889