hotips
hotips

Reputation: 2631

Find query inside MongoDB reduce

I have two collections : one with the raw data from devices, one with the device configuration

I use map reduce to treat the raw data from devices. I need to get the configuration parameters inside the reduce step.

Is it possible ?

Thanks in advance

UPDATE : I have a lot of data to treat 400000 documents per day and around 4000 configuration documents. Thus I have to make a join between the two collections and inject that in map/reduce ? Is this the best way to do ?

Upvotes: 0

Views: 587

Answers (1)

Remon van Vliet
Remon van Vliet

Reputation: 18595

No. Map/reduce should always use the collection data it is invoked on. If you need the configuration data you will have to make sure it is inside your raw device data before invoking the map/reduce. Since m/r is just JavaScript being executed server-side so it is technically possible to query other collections but it can break (sharding comes to mind).

Upvotes: 4

Related Questions