我有一个将variants
其specifications
作为子文档调用的集合。使用点符号搜索变体对我有用(但不使用索引),而使用子文档格式返回零结果(但使用索引)。我做错了什么?
> db.variants.getIndexes();
[
{
"v" : 1,
"key" : {
"_id" : 1
},
"ns" : "automobile.variants",
"name" : "_id_"
},
{
"v" : 1,
"key" : {
"specifications" : 1
},
"ns" : "automobile.variants",
"name" : "specifications_1"
}
]
> db.variants.find({"specifications" : { "Body" : "SUV" }}).explain()
{
"cursor" : "BtreeCursor specifications_1",
"nscanned" : 0,
"nscannedObjects" : 0,
"n" : 0,
"millis" : 0,
"nYields" : 0,
"nChunkSkips" : 0,
"isMultiKey" : false,
"indexOnly" : false,
"indexBounds" : {
"specifications" : [
[
{
"Body" : "SUV"
},
{
"Body" : "SUV"
}
]
]
}
}
> db.variants.find({"specifications.Body" : "SUV" }).explain()
{
"cursor" : "BasicCursor",
"nscanned" : 787,
"nscannedObjects" : 787,
"n" : 176,
"millis" : 0,
"nYields" : 0,
"nChunkSkips" : 0,
"isMultiKey" : false,
"indexOnly" : false,
"indexBounds" : {
}
}