Reputation: 591
I'm querying data from some collection, In my pipeline I have the stages : match, skip, limit. When i add the sort stage, I GET THE ERROR MESSAGE : mongodb fieldpath field names may not start with $. The code is like:$collection->aggregate(array(
array('$match'=>$my_query),array('$limit'=>$my_limit),
array('skip'=>$my_skip),array('$sort'=>array('$natural'=>-1)))
Upvotes: 0
Views: 720
Reputation: 4117
This is a known mongo issue.
But, what does it mean to do a $natural sort at the end of the aggregation pipeline?
If it is ascending, well, that's the same as not having the sort at all. If descending, it means getting the results in a reverse order.
Upvotes: 1