Using Atlas aggregation wizard on a sample collection, the $out stage returns
An unknown error occurred
When running the aggregation inside a function, the result is:
(AtlasError) $out is not allowed or the syntax is incorrect
Code here:
exports = function(payload, response) {
const mongodb = context.services.get("mongodb-atlas");
const readColl = mongodb.db("temp_db").collection("temp_read")
const writeColl = mongodb.db("temp_db").collection("temp_write")
const myAgg = readColl.aggregate([ { $sample: { size: 2 } }, { $out: "temp_write" } ])
return myAgg
}
Any advice from the community?
MaBeuLux88
(Maxime Beugnet)
March 28, 2023, 10:56pm
#2
Hi @enjoywithouthey ,
Can you share the pipeline and which sample collection you used?
Also which cluster Tier are you using in Atlas and which version ? Anything out of the ordinary with your cluster?
My Tier is $0.1/1M Serverless
The sample data I made up. It’s in a collection I’m calling temp_read
I’m selecting some random documents and pushing them to an empty collection called temp_write
$merge in a previous pipeline worked fine. $out is giving errors.
Here’s the sample data:
[
{
"1": "A"
},
{
"2": "B"
},
{
"3": "C"
},
{
"4": "D"
},
{
"5": "E"
},
{
"6": "F"
},
{
"7": "G"
}
]
Pipeline:
[
{
$sample:
{
size: 2,
},
},
{
$out:
"temp_write",
},
]
Thanks for your help!
@MaBeuLux88 I did a little digging and found something interesting…
On some previous Clusters I made for tutorials, version 5.0.15 installs automatically under the M0 free tier. No problems with $out.
I made a recent paid production M1 Cluster (the cluster causing the problem with $out) and that cluster is version 6.2.1. The problem with $out persists.
Hope this helps.
1 Like
@MaBeuLux88 to verify, I just spun-up a M10 Dedicated Cluster, which allowed me to choose v5 in the advanced configuration (instead of v6).
$out works no problem.
1 Like
MaBeuLux88
(Maxime Beugnet)
March 29, 2023, 12:30am
#7
I was able to reproduce on a serverless instance as well !
Ok, thanks.
Maybe that we’ve created a thread on this subject, the results will be scrapped and show up in search engines. Appreciate the help.
1 Like
MaBeuLux88
(Maxime Beugnet)
March 29, 2023, 3:14pm
#10
Definitely!
I wasn’t aware of this limitation of serverless. Hopefully it goes away soon.
But the error message could be better. I’ll create a ticket to improve it. It would have been easier for you to understand the source of the problem.
Cheers,
Maxime.
system
(system)
Closed
April 3, 2023, 3:15pm
#11
This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.