Link walking

Andrew Berman rexxe98 at
Fri May 6 15:31:09 EDT 2011

The results from one phase get passed on to the next phase, so if you want
both data sets you need to run two different map-reduce queries.  If you
want the results from the link phase you need to run a link phase in
addition to a map phase (link first and then you can do the map phase with
Riak.mapValuesJson, which will give you the object that the link is pointing

On Fri, May 6, 2011 at 12:14 PM, Joshua Hanson <joshua.b.hanson at>wrote:

> The initial map phase is to grab the values from the input phase (.add()).
> I want these values as well as the ones exposed from .link() but not sure
> how to express it.
> _________________________________
> Joshua Hanson
> e: joshua.b.hanson at
> On Fri, May 6, 2011 at 3:01 PM, Andrew Berman <rexxe98 at> wrote:
>> I don't totally understand what you're doing in your code, but it looks
>> like you have the map phase before the link phase which doesn't make sense
>> since you want the data from the link phase passed on to the map phase, not
>> the other way around.
>> On Fri, May 6, 2011 at 9:37 AM, Joshua Hanson <joshua.b.hanson at>wrote:
>>> In my map/reduce query I would like to keep the input data
>>> and also data from the link-walking phase.
>>> Here is some sample code:
>>> #insert message
>>>'messages', 'josh-123', 'secret message', function(err, message)
>>> {
>>> #insert people object with link to message we just inserted
>>>'people', 'josh', {'profession': 'developer'},
>>>  { links: [{ bucket: 'messages', key: 'josh-123', 'tag': 'message' }]},
>>>  function(err, data) {
>>>  db.add([['people', 'josh']])
>>> .map({ 'source': 'Riak.mapValuesJson', 'keep': true})
>>>  .link({ 'bucket': 'messages'})
>>> .run(function(err, data) {
>>>  if (err) return console.log(err);
>>>  console.log(data);
>>> })
>>>  }
>>> )
>>> })
>>> So, if I remove the 'link' phase I get the correct object from the map
>>> phase
>>> but if I instead remove the 'map' phase, I get the correct object from
>>> link phase.
>>> However, having both together does not work. Is it possible to get at
>>> both the original data and the data from link-walking in the same query?
>>> _________________________________
>>> Joshua Hanson
>>> e: joshua.b.hanson at
>>> _______________________________________________
>>> riak-users mailing list
>>> riak-users at
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the riak-users mailing list