在Map/Reduce中运行MongoDB查询 [英] Running MongoDB Queries in Map/Reduce

查看:80
本文介绍了在Map/Reduce中运行MongoDB查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以运行MongoDB命令(如查询)以获取其他数据或通过MongoDB的MapReduce命令进行更新.是在Map中还是在Reduce函数中?

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?

这是否完全荒唐可笑?目前,我有一些文档使用MongoDB DBReference命令引用单独的集合.

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

感谢您的帮助!

推荐答案

是否可以从MongoDB的MapReduce命令中运行MongoDB命令....

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.

  • 问题1 :指数级工作. M/R已经非常紧张并且记录不佳.添加查询很容易使M/R失去控制.
  • 问题2 :上下文.假设您正在运行分片M/R,并且正在查询未分片的集合.当前上下文甚至有这种联系吗?
  • 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?

您基本上是在尝试实现JOIN逻辑,而MongoDB没有联接.取而代之的是,您可能需要通过在几组数据上运行一些循环来分两个阶段构建最终数据.

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.

这篇关于在Map/Reduce中运行MongoDB查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆