Running MongoDB queries with >2 aggregation pipelines in $facet results in “Connect Failed” dialogue box

拟墨画扇 提交于 2019-12-13 20:35:49

问题


I have tried a faceted search over my collections, and I need the entire documents which match the criteria as outputs. As I need to group by different combinations of group criteria, I require to do the faceted search. However, whenever the number of aggregation pipelines in the facet is exceeding 2, an alert box pops up saying "Failed to execute script. Error: Connect Failed" However, the connection to the database is never lost, and if I reduce the number of pipelines, the query again successfully executes. What might be the problem here?

I tried increasing the shell timeout to ridiculous amounts, but that didn't help:

https://blog.robomongo.org/robomongo-is-robo-3t/#4a

I also allowed disk use as advised by the following link, if the query was not being able to run using just the RAM:

https://docs.mongodb.com/manual/core/aggregation-pipeline-limits/

but the effect is the same.

I'm producing the query as it stands below:

db.getCollection('PERSON-DB').aggregate([

{
    $facet: {
        "categorizedBySSN":[
            {"$group" : 
                {_id:{source:"$ssn"}, 
                        count:{$sum:1},
              entries: { $push: "$$ROOT" }
                       }
            }
        ],
        "categorizedBySSN+FirstName":[
            {"$group" : 
                {_id:{
                ssn:"$ssn",
                firstName: "$name.first"}, 
                        count:{$sum:1},
              entries: { $push: "$$ROOT" }
                       }
            }
        ],
        "categorizedByFirstName+LastName+Address":[
            {
             $unwind: "$postalAddresses"
            },
            {"$group":
                {_id:{
                    firstName: "$name.first",
                    lastName: "$name.last",
                    country: "$postalAddresses.country.name", 
                    state: "$postalAddresses.state.code", 
                    city: "$postalAddresses.city", 
                    street: "$postalAddresses.streetAddress"
                    },
                count:{$sum:1},
                entries:{$push:"$$ROOT"}
                }
            }
        ]
    }
}
], { allowDiskUse:true, cursor:{})

来源:https://stackoverflow.com/questions/56004245/running-mongodb-queries-with-2-aggregation-pipelines-in-facet-results-in-conn

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!