Running MongoDB Queries in Map/Reduce

醉酒当歌 提交于 2019-12-23 04:04:47

问题


Is it possible to run MongoDB commands like a query to grab additional data or to do an update from with in MongoDB's MapReduce command. Either in the Map or the Reduce function?

Is this completely ludicrous to do anyways? Currently I have some documents that refer to separate collections using the MongoDB DBReference command.

Thanks for the help!


回答1:


Is it possible to run MongoDB commands... from within MongoDB's MapReduce command.

In theory, this is possible. In practice there are lots of problems with this.

  • Problem #1: exponential work. M/R is already pretty intense and poorly logged. Adding queries can easily make M/R run out of control.
  • Problem #2: context. Imagine that you're running a sharded M/R and you are querying into an unsharded collection. Does the current context even have that connection?

You're basically trying to implement JOIN logic and MongoDB has no joins. Instead, you may need to build the final data in a couple of phases by running a few loops on a few sets of data.



来源:https://stackoverflow.com/questions/7651808/running-mongodb-queries-in-map-reduce

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!