Why does MongoDB still support MapReduce, but actively discourage people from using it? Looking at the MongoDB documentation I see that users are discouraged from using MapReduce in favour of the Aggregation pipeline.
For example, on this page in the documentation.
But the same notice is ambiguous in terms of whether the Aggregation Framework completely replaces MapReduce or not:

Various map-reduce operations can be rewritten using aggregation pipeline operators, such as $group, $merge, etc. For map-reduce operations that require custom functionality, MongoDB provides the $accumulator and $function aggregation operators starting in version 4.4.

Does this mean that &quot;every conceivable&quot; MapReduce configuration can be replicated via the Aggregation Framework or not?
I understand that the MapReduce execution context might be slower than the Aggregation pipeline since the former requires a JavaScript engine which is/was/still is? slower than the Aggregation pipeline implementation.
Unlike other features, MapReduce has NOT been labeled as deprecated so far as I know. So, my question is:
Is MapReduce completely replaced (for every single possible use-case) by the Aggregation Framework? Or are there use-cases where MapReduce still provides for greater flexibility?
The answer is no, the aggregation framework does not replace &quot;every conceivable&quot; MapReduce configuration. Without becoming a general purpose MapReduce framework with fully customizable functions, it can't. That's what you get with the existing MapReduce functionality - any functions you want (as long as they can be written in Javascripts of course).
I haven't used it in a long time (years), but it is not just because of the use of the javascript engine that the MapReduce funcionality is slower, it still does things like taking a global write lock (docs) when writing output which will block all other operations on a mongod - ouch. Even several version prior to this, when the Aggregation Framework was nowhere near as featureful as it is now the advice was: if you can use the aggregation framework, do so, only use MapReduce if you have no other choice.