问题
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