Running MongoDB Queries in Map/Reduce?

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.

Thank you for the reply. Basically I have a situation where I have a group of products for merchants and I wanted to do some aggregation of the product prices. Attached to the Products I have the MerchantID from the DB Ref.My Key in my emit would be the MerchantID and then emit the product price / quantity.

Just to tidy things up for the final result collection I wanted to add in the Merchant Name rather than the MerchantID. The Merchant Names are stored in a separate collection. – whobutsb Oct 4 at 22:17 1 In your case, you have two options.

(1) -> denormalize and store the merchant name with the product data. (2) -> after the M/R, update the output collection with the merchant name. Takes an extra step, but you'll get the right result and it's easier to shard.

Option (3) -> query the required names when running queries against the data. It's a manual join, but if you want to display more than just the name on that screen, you'll end up doing this anyways. – Gates VP Oct 5 at 0:42.

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

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions