MongoDB - $ maxscan选项

时间:2014-02-26 22:13:28

标签: mongodb

C:\>mongo

C:\>C:\Programs\MongoDB\bin\mongo.exe
MongoDB shell version: 2.4.8
connecting to: test
Welcome to the MongoDB shell!
[test] 2014-02-26 17:09:35.933 >>> db.people.count();
9
[test] 2014-02-26 17:09:39.10 >>> db.people.find({})._addSpecial("$maxscan", 5);
{
        "_id" : ObjectId("530e61be188483458f1edca7"),
        "name" : "joe",
        "random" : 0.7170755963306874
}
{
        "_id" : ObjectId("530e61c2188483458f1edca8"),
        "name" : "mark",
        "random" : 0.6132313262205571
}
{
        "_id" : ObjectId("530e61c7188483458f1edca9"),
        "name" : "john",
        "random" : 0.07292630313895643
}
{
        "_id" : ObjectId("530e621c188483458f1edcaa"),
        "name" : "allen",
        "random" : 0.09901093109510839
}
{
        "_id" : ObjectId("530e636f188483458f1edcab"),
        "name" : "kevin",
        "random" : 0.9719919066410512
}
{
        "_id" : ObjectId("530e6375188483458f1edcac"),
        "name" : "nicola",
        "random" : 0.4626409418415278
}
{
        "_id" : ObjectId("530e6428188483458f1edcad"),
        "name" : "peter",
        "random" : 0.8568310006521642
}
{
        "_id" : ObjectId("530e642d188483458f1edcae"),
        "name" : "tim",
        "random" : 0.5209994465112686
}
{
        "_id" : ObjectId("530e6437188483458f1edcaf"),
        "name" : "joseph",
        "random" : 0.6217151982709765
}
[test] 2014-02-26 17:09:51.76 >>>

我在这个系列中有9个文件 我用上面的find查询 选项_addSpecial("$maxscan", 5)

然而,还有9份文件被退回 我期待退回5份文件 为什么这样做?

我查看了这里的文档

http://docs.mongodb.org/manual/reference/operator/meta/maxScan/

但我认为它没有提供任何线索。

1 个答案:

答案 0 :(得分:2)

MongoDB 类型敏感区分大小写,这意味着您必须完全按原样编写运算符。你写的是$maxscan,但实际上,根据文档是$maxScan