mapValuesJson (
https://github.com/basho/riak_kv/blob/master/priv/mapred_builtins.js#L45)
takes a JSON formatted string and returns it as a JavaScript object. You'll
still need to do something with it to make the magic happen.

mr = Riak::MapReduce.new(client)
mr.add("stocks")
mr.map("function(value, keyData, arg) {
  var data = Riak.mapValuesJson(value)[0];
  if (data.abr == "GOOG") {
    // magic happens here
    return [data];
  }
}", :keep => true, :language => "JavaScript")



Jeremiah Peschka
Microsoft SQL Server MVP
MCITP: Database Developer, DBA


On Thu, Jan 27, 2011 at 7:37 AM, Joshua Partogi <[email protected]>wrote:

> Hi all,
>
> I am trying to do map reduce with the ruby client as such:
> client = Ripple.client
> Riak::MapReduce.new(client).
>                   add("stocks").
>                   map("Riak.mapValuesJson", :arg => "GOOG", :keep => true)
>
> where the JSON document inside the bucket is as such:
>
> { "abr" : "GOOG" }
> { "abr" : "AAPL" }
>
> However instead of returning only one result it is returning all values in
> the bucket.
>
> What am I doing wrong here?
>
> Thanks heaps for the help.
>
> --
> http://twitter.com/jpartogi <http://twitter.com/scrum8>
>
> _______________________________________________
> riak-users mailing list
> [email protected]
> http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com
>
>
_______________________________________________
riak-users mailing list
[email protected]
http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com

Reply via email to