mongoDB在索引字段上是不同的

时间:2012-05-01 23:33:11

标签: mongodb mongodb-query nosql

我试图在包含在唯一索引中的字段上使用distinct。所有索引字段都不起作用。任何其他领域都很有效。以下是运行以下命令时的统计信息输出:

(非索引字段)

db.runCommand( { distinct: 'businesses', key: 'website' } )

"values" : [
    blah blah blah
],
"stats" : {
        "n" : 36,
        "nscanned" : 36,
        "nscannedObjects" : 36,
        "timems" : 0,
        "cursor" : "BasicCursor"
},
"ok" : 1

(索引字段)

db.runCommand( { distinct: 'businesses', key: 'state' } );

{
        "values" : [ ],
        "stats" : {
                "n" : 0,
                "nscanned" : 0,
                "nscannedObjects" : 0,
                "timems" : 0,
                "cursor" : "BtreeCursor address_1_unit_1_city_1_state_1_zip_1"
        },
        "ok" : 1
}

如何在索引中涉及的那些字段上使用distinct?

0 个答案:

没有答案