MongoDB查询失败,没有查询执行计划

uqjltbpv  于 2023-03-01  发布在  Go
关注(0)|答案(1)|浏览(236)

在MongoDB中执行以下查询

db.getCollection("translations").find({namespace: "public_frontend"})

会导致以下错误

Query failed with error code 291 and error message 'error processing query: ns=i18n_api.translations batchSize=21Tree: namespace $eq "public_frontend" Sort: {} Proj: {} planner returned error :: caused by :: No indexed plans available, and running with 'notablescan'' on server

该集合具有以下索引:

[
    {
        "v" : 2.0,
        "key" : {
            "_id" : 1.0
        },
        "name" : "_id_"
    },
    {
        "v" : 2.0,
        "key" : {
            "key" : 1.0,
            "namespace" : 1.0
        },
        "name" : "key_1_namespace_1",
        "unique" : true,
        "sparse" : true
    }
]
bogh5gae

bogh5gae1#

这可能是因为您尚未在mongoDB中创建索引

相关问题