[DOCS-16604] $documents stage can't be used on a collection-level aggregation Created: 26/Jan/24  Updated: 26/Jan/24

Status: Backlog
Project: Documentation
Component/s: manual, Server
Affects Version/s: None
Fix Version/s: None

Type: Task Priority: Minor - P4
Reporter: Jérôme Tamarelle Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: Improvement, feature
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to SERVER-85768 Improve error message when $documents... Needs Scheduling
URL(s): https://www.mongodb.com/docs/manual/reference/operator/aggregation/documents/
Participants:
Days since reply: 1 week, 5 days ago

 Description   

The mongo server returns an error if we try to use the $documents stage as first stage of an aggregation run on a collection.

 

Enterprise test> db.test.aggregate([ { $documents: [{ nb: [1, 2, 3] }] }, { $project: { total: { $sum: ["$nb"] } } }] )
MongoServerError: '$documents' can only be run with {aggregate: 1}

I suggest updating the Behavior section of the $documents page to say so. Especially since the error message from the server is not very clear for someone that ignore the meaning of {{

{aggregate: 1}

}}

 


Generated at Thu Feb 08 08:15:44 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.