Pass keyarg from one map phase to another?

Daniel Reverri dan at
Fri Mar 23 12:18:25 EDT 2012

Hi Mat, 

Yes, a map function may return a three element array with the third element being used as keydata to a subsequent map phase. A quick example:

# create an object
curl http://localhost:8098/riak/bucket/key -XPUT -d 'hello' -H 'content-type:text/plain'

# example MapReduce query
curl http://localhost:8098/mapred -XPOST -H 'content-type:application/json' -d '{"inputs":[["bucket","key"]],"query":[{"map":{"language":"javascript","source":"function(v) { return [[\"bucket\",\"key\",\"keyarg\"]] }"}},{"map":{"language":"javascript","source":"function(v, keyData) { return [keyData] }"}}]}'


Daniel Reverri
Developer Advocate
Basho Technologies, Inc.
dan at
Sent with Sparrow (

On Friday, March 23, 2012 at 8:37 AM, Matthew A. Brown wrote:

> For situations in which one map phase passes output to a subsequent
> map phase, the documentation states:
> These map functions filter their inputs based on the arg and
> return bucket-key pairs for a subsequent map phase
> Is it possible to also return a keyarg? So a three-element array?
> Thanks!
> Mat
> _______________________________________________
> riak-users mailing list
> riak-users at (mailto:riak-users at

More information about the riak-users mailing list