Writing Map-Reduce Views


Hi all, I’m trying to create a Map Reduce view as per the following scenario -

Map would emit key value-pair as :-
(Key1, 1), (Key1,4) , (Key1,3), (Key1,5), (Key1,5), (Key2,1), (Key3,6) (Key3,2) …

and after Reduce, expected output is the Maximum value for each key:
(Key1, 5)
(Key2, 1)
(Key3, 6)
Number of Key-value pairs are in hundreds currently. But it’s expected to be in the range of thousands.
Can some please help me in writing the reducer for the above scenario. Thanks


Hey. In the map function, you can emit(Key, value) as the pair, and use the built it _STAT as the reduce function. While querying, if you want the global maximum, set group=false and if you want the maximum per key, set group=true.