Mongodb &引用;InternalError“提供统计信息时没有可用的计划”;带解释的聚合

Mongodb &引用;InternalError“提供统计信息时没有可用的计划”;带解释的聚合,mongodb,aggregation-framework,Mongodb,Aggregation Framework,当我使用explain运行聚合时,如前所述,我得到以下结果。。。 { “阶段”:[ { “$cursor”:{ ... “planError”:“InternalError没有可提供统计数据的计划” } 对这里发生的事情有什么想法吗?我真的需要能够看到我的$match阶段正在使用什么(如果有)索引。我稍微调整了一下您的查询(在前面添加一个匹配项,因为我不想为所有文档展开标记数组): 得到: { "stages" : [ { "$cursor"

当我使用explain运行聚合时,如前所述,我得到以下结果。。。

{
“阶段”:[
{
“$cursor”:{
...
“planError”:“InternalError没有可提供统计数据的计划”
}

对这里发生的事情有什么想法吗?我真的需要能够看到我的
$match
阶段正在使用什么(如果有)索引。

我稍微调整了一下您的查询(在前面添加一个匹配项,因为我不想为所有文档展开标记数组):

得到:

{
    "stages" : [
        {
            "$cursor" : {
                "query" : {
                    "$or" : [
                        {
                            "Tags._id" : "tag1"
                        },
                        {
                            "Tags._id" : "tag2"
                        }
                    ]
                },
                "plan" : {
                    "cursor" : "BtreeCursor ",
                    "isMultiKey" : false,
                    "scanAndOrder" : false,
                    "indexBounds" : {
                        "Tags._id" : [
                            [
                                "tag1",
                                "tag1"
                            ],
                            [
                                "tag2",
                                "tag2"
                            ]
                        ]
                    },
                    "allPlans" : [
                        {
                            "cursor" : "BtreeCursor ",
                            "isMultiKey" : false,
                            "scanAndOrder" : false,
                            "indexBounds" : {
                                "Tags._id" : [
                                    [
                                        "tag1",
                                        "tag1"
                                    ],
                                    [
                                        "tag2",
                                        "tag2"
                                    ]
                                ]
                            }
                        }
                    ]
                }
            }
        },
        {
            "$unwind" : "$Tags"
        },
        {
            "$match" : {
                "$or" : [
                    {
                        "Tags._id" : "tag1"
                    },
                    {
                        "Tags._id" : "tag2"
                    }
                ]
            }
        },
        {
            "$group" : {
                "_id" : "$_id",
                "count" : {
                    "$sum" : {
                        "$const" : 1
                    }
                }
            }
        },
        {
            "$sort" : {
                "sortKey" : {
                    "count" : -1
                }
            }
        }
    ],
    "ok" : 1
}
虽然这并不能完全解释为什么您的操作会返回planError,但也许它可以帮助您了解如何返回planError


这似乎是一个MongoDB 2.6错误。请检查。

在我的Rails应用程序中有相同的问题,通过重新启动Rails服务器修复了它。
MongoDB版本是2.6.4。

我通过重建集合上的所有索引来解决这一问题。虽然不太完美,但错误现在已经消失了。

您看到这一结果的整个语句是什么?
{
    "stages" : [
        {
            "$cursor" : {
                "query" : {
                    "$or" : [
                        {
                            "Tags._id" : "tag1"
                        },
                        {
                            "Tags._id" : "tag2"
                        }
                    ]
                },
                "plan" : {
                    "cursor" : "BtreeCursor ",
                    "isMultiKey" : false,
                    "scanAndOrder" : false,
                    "indexBounds" : {
                        "Tags._id" : [
                            [
                                "tag1",
                                "tag1"
                            ],
                            [
                                "tag2",
                                "tag2"
                            ]
                        ]
                    },
                    "allPlans" : [
                        {
                            "cursor" : "BtreeCursor ",
                            "isMultiKey" : false,
                            "scanAndOrder" : false,
                            "indexBounds" : {
                                "Tags._id" : [
                                    [
                                        "tag1",
                                        "tag1"
                                    ],
                                    [
                                        "tag2",
                                        "tag2"
                                    ]
                                ]
                            }
                        }
                    ]
                }
            }
        },
        {
            "$unwind" : "$Tags"
        },
        {
            "$match" : {
                "$or" : [
                    {
                        "Tags._id" : "tag1"
                    },
                    {
                        "Tags._id" : "tag2"
                    }
                ]
            }
        },
        {
            "$group" : {
                "_id" : "$_id",
                "count" : {
                    "$sum" : {
                        "$const" : 1
                    }
                }
            }
        },
        {
            "$sort" : {
                "sortKey" : {
                    "count" : -1
                }
            }
        }
    ],
    "ok" : 1
}