0

I have a map functions as:

emit(this_id,this),

now I want to iterate through each key in the reduce function,is their a way I can proceed with this problem, having no clue how to proceed.

Chris Heald
  • 61,439
  • 10
  • 123
  • 137
Phalguni Mukherjee
  • 623
  • 3
  • 11
  • 29
  • This sounds dangerously like an [XY Problem](http://meta.stackexchange.com/questions/66377/what-is-the-xy-problem). Maybe you would find better help when you would explain the actual problem you want to solve instead of seeking help with implementing a solution which might be misguided. – Philipp Aug 08 '13 at 08:45
  • Please provide: input documents, problem description and expected output. It's likely that your problem can be solved with a nice application of the Aggregation Framework as well. – Derick Aug 08 '13 at 10:13

1 Answers1

0

The reduce function operates on a set of some (not necessarily all) entries which were found to have the same key. You can not iterate through all keys at this point, because the reduce functions are distributed. A host of your database might not even know about some keys because they are processed on another cluster. So whatever you attempt to do, it won't work that way.

You don't explain what problem you actually want to solve, but your idea for a possible solution seems to go into the wrong direction. I would recommend you to create a new question explaining your actual problem and seeing what stackoverflow can come up with.

Philipp
  • 67,764
  • 9
  • 118
  • 153
  • I do the following and it works :function Reduce(key, values) { var data={} values.forEach(function(val) { for (var key in val) { if(val[key]&&!(0==val[key].length)){ data[key]=val[key]; } } }); return data; } – Phalguni Mukherjee Aug 08 '13 at 09:29