[SERVER-33393] The 'cursor' option is required, except for aggregate with the explain argument Created: 20/Feb/18  Updated: 27/Oct/23  Resolved: 20/Feb/18

Status: Closed
Project: Core Server
Component/s: Aggregation Framework
Affects Version/s: 3.6.2
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Amrut Gaikwad Assignee: Ramon Fernandez Marina
Resolution: Works as Designed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
is related to SERVER-38234 The 'cursor' option is required.. eve... Closed
Operating System: ALL
Participants:

 Description   

I have upgraded my MongoDB version from 3.4 to 3.6 and my PHP driver version is "1.6.8"
Below query works fine on version 3.4 but now giving error "The 'cursor' option is required, except for aggregate with the explain argument".

 $cursor=$collection_discussion->aggregate([
                    [ '$match' => ['_id' => $discussion_id]],
                    [
                        '$project' => [
                            'comments'=> [
                                '$filter' => [
                                    'input'=> '$comments',
                                    'as'=> 'comment',
                                    'cond' => [ '$eq' => [ '$$comment.group_id',$group_id ] ]
                                ]
                            ]
                        ]
                    ],[
                        '$project' => [
                            'comments'=> [
                                '$slice' => [
                                    [
                                        '$slice' => [
                                            '$comments',
                                            [
                                                '$subtract' => [ [ '$size' => [ '$comments' ] ], $list_count ]
                                            ]
                                        ]
                                    ], $lastRecordsLimit
                                ]
                            ]
                        ]
                    ]
                ]);



 Comments   
Comment by Ramon Fernandez Marina [ 26/Nov/18 ]

josef.sabl, will you please open a new SERVER ticket describing your issue? Please specify with version of MongoDB you're using and attach logs as needed.

Thanks,
Ramón.

Comment by Josef Sábl [ 23/Nov/18 ]

I have an aggregation WITH the cursor and still get the error, now what?

db.StatEvent.aggregate([
    {
        $match: {
            'time': {$gt: timeLastRun}
        }
    },
    {$out: tempAggrName}
], {
	cursor: { batchSize: 0 }
});

When I remove the $out stage it works.

Comment by Ramon Fernandez Marina [ 20/Feb/18 ]

ggaikwad.amrut@gmail.com, in MongoDB 3.6 you need to specify how to handle the result of an aggregate() command:

Changed in version 3.6: MongoDB 3.6 removes the use of aggregate command without the cursor option unless the command includes the explain option. Unless you include the explain option, you must specify the cursor option.

Please note that the SERVER project is for reporting bugs or feature suggestions for the MongoDB server. For MongoDB-related support discussion please post on the mongodb-user group or Stack Overflow with the mongodb tag, where your question will reach a larger audience. A question like this involving more discussion would be best posted on the mongodb-user group. See also our Technical Support page for additional support resources.

Regards,
Ramón.

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