私は MongoDB を初めて使用し、いくつかの基礎を試してみましたが、これには驚きました。中心的な概念を誤解していると思いますが、ここで何が起こっているのか誰か教えてもらえますか?
公式の MongoDB C# ドライブを使用して、これらのドキュメントの 10,0000 個を「ロット」と呼ばれる db コレクションに挿入しました。
// Insert some test data
const double price = 29.99;
var bsonDoc = new BsonDocument {
{"glossary", new BsonDocument {
{"title", "example glossary"},
{"GlossDiv", new BsonDocument {
{"title", "S"},
{"price", new BsonDouble(price)},
...
/* full doc chunk removed here for brevity */
...
};
...
const int numObjects = 10000;
for (int i = 0; i < numObjects; i++)
col.Insert(new BsonDocument(bsonDoc));
...
C# ドライバーで見たものを信じられなかったので、シェルでこれを試しましたが、結果は同じです。
db.lots.group({key:{"glossary.GlossDiv.title":true}, reduce:function(obj,out){out.total+=obj.glossary.GlossDiv.price;}, initial:{total:0 } }) [ { "glossary.GlossDiv.title" : "S", "合計" : 299899.99999995757 } ]
私が間違っている場合は修正してください。