Map Reduce with Python

Matt Black at
Wed Jun 13 00:04:18 EDT 2012

Hello list,

In an M/R query, I'd like to be able to merge objects from two different
buckets in my output. So my process is a map phase for each bucket, with a
link phase in the middle, and a reduce phase to do a bit of merge
processing at the end.

client = riak.RiakClient(RIAK_HOST, RIAK_PORT)
query = client.add("carts")"function(v) { return [[ v.bucket, v.key,
Riak.mapValuesJson(v)[0] ]]; }", {'keep': False})"cart-products", "cart-products", False)"products", "product", False)"function(v) { return [ Riak.mapValuesJson(v)[0] ]; }", {'keep':
query.reduce("function(values) { return values; }")

This query will return only objects from the "products" bucket.

I tried using the "keep" flags on each map phase, but in this case the I
get output from each map phase and the reduce phase appears to be ignored -
which is somewhat unexpected.

Please advise on changes or things I could try.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the riak-users mailing list