@@ -3059,6 +3059,8 @@ def _map_reduce(self, map, reduce, out, session, read_pref, **kwargs):
3059
3059
def map_reduce (self , map , reduce , out , full_response = False , session = None , ** kwargs ):
3060
3060
"""Perform a map/reduce operation on this collection.
3061
3061
3062
+ **DEPRECATED** - Use :meth:`aggregate` instead.
3063
+
3062
3064
If `full_response` is ``False`` (default) returns a
3063
3065
:class:`~pymongo.collection.Collection` instance containing
3064
3066
the results of the operation. Otherwise, returns the full
@@ -3100,6 +3102,15 @@ def map_reduce(self, map, reduce, out, full_response=False, session=None, **kwar
3100
3102
3101
3103
.. seealso:: :doc:`/examples/aggregation`
3102
3104
3105
+ .. versionchanged:: 3.13
3106
+ Support for this function is deprecated in
3107
+ MongoDB 4.0, and it is removed in PyMongo 4.0. Migrate to
3108
+ :meth:`aggregate`. For more guidance on this migration see:
3109
+
3110
+ - https://docs.mongodb.com/manual/reference/map-reduce-to-aggregation-pipeline/
3111
+ - https://docs.mongodb.com/manual/reference/aggregation-commands-comparison/
3112
+
3113
+ .. _mapReduce command: https://docs.mongodb.com/manual/reference/command/mapReduce/
3103
3114
.. versionchanged:: 3.4
3104
3115
Added the `collation` option.
3105
3116
.. versionchanged:: 2.2
@@ -3110,6 +3121,11 @@ def map_reduce(self, map, reduce, out, full_response=False, session=None, **kwar
3110
3121
.. seealso:: The MongoDB documentation on `mapreduce <https://dochub.mongodb.org/core/mapreduce>`_.
3111
3122
3112
3123
"""
3124
+ warnings .warn (
3125
+ 'map_reduce is deprecated, use aggregate instead' ,
3126
+ DeprecationWarning ,
3127
+ stacklevel = 2
3128
+ )
3113
3129
if not isinstance (out , (string_type , abc .Mapping )):
3114
3130
raise TypeError (
3115
3131
"'out' must be an instance of " "%s or a mapping" % (string_type .__name__ ,)
@@ -3129,6 +3145,8 @@ def map_reduce(self, map, reduce, out, full_response=False, session=None, **kwar
3129
3145
def inline_map_reduce (self , map , reduce , full_response = False , session = None , ** kwargs ):
3130
3146
"""Perform an inline map/reduce operation on this collection.
3131
3147
3148
+ **DEPRECATED** - Use :meth:`aggregate` instead.
3149
+
3132
3150
Perform the map/reduce operation on the server in RAM. A result
3133
3151
collection is not created. The result set is returned as a list
3134
3152
of documents.
@@ -3152,12 +3170,26 @@ def inline_map_reduce(self, map, reduce, full_response=False, session=None, **kw
3152
3170
helper method, e.g.::
3153
3171
3154
3172
>>> db.test.inline_map_reduce(map, reduce, limit=2)
3173
+ .. versionchanged:: 3.13
3174
+ Support for this function is deprecated in
3175
+ MongoDB 4.0, and is removed in PyMongo 4.0. Migrate to
3176
+ :meth:`aggregate`. For more guidance on this migration see:
3177
+
3178
+ - https://docs.mongodb.com/manual/reference/map-reduce-to-aggregation-pipeline/
3179
+ - https://docs.mongodb.com/manual/reference/aggregation-commands-comparison/
3155
3180
3181
+ .. _mapReduce command: https://docs.mongodb.com/manual/reference/command/mapReduce/
3156
3182
.. versionchanged:: 3.6
3157
3183
Added ``session`` parameter.
3158
3184
.. versionchanged:: 3.4
3159
3185
Added the `collation` option.
3160
3186
"""
3187
+ warnings .warn (
3188
+ 'inline_map_reduce is deprecated, use aggregate instead' ,
3189
+ DeprecationWarning ,
3190
+ stacklevel = 2
3191
+ )
3192
+
3161
3193
res = self ._map_reduce (map , reduce , {"inline" : 1 }, session , self .read_preference , ** kwargs )
3162
3194
3163
3195
if full_response :
0 commit comments