Venki, You can specify an argument in your map function and hand the argument's value over when running the MapReduce request. The part in your JavaScript code is as simple as adding a second and a third argument to your function like so, with the third argument being the relevant one:
function map(value, keydata, args) { } Whatever ends up in args can be specified via the MapReduce API. Suppose you're using the Ruby client, you can specify an argument for every map phase you add to a request. Notice the :arg option in the last line: results = Riak::MapReduce.new(client). add("artists","Beatles"). map("function(value, keydata, args) {return [args]'}", :keep => true, :arg => {:paul => true).run The hash in this example ends up as a JSON structure passed into the function, properly deserialized into a JavaScript object before the call of course. The same in pure HTTP using curl would look like this: curl -v -d '{"inputs":[["artists","Beatles"]], "query":[{"map":{"language":"javascript","source":"function(value, keydata, args) {return [args];}","arg": {"paul": true}}}]}' -H "Content-Type: application/json" http://127.0.0.1:8098/mapred Cheers, Mathias http://riakhandbook.com On Tuesday, 3. July 2012 at 09:45, Venki Yedidha wrote: > Hi All, > I wrote a map function to retrieve statistics for a particular data. > However, I want to make this function accessible for many other data > retrievals. For this, I need to send arguments to my function written in > javascript. I didn't find examples on sending arguments to map function.. > Please help me on above. > > Thanks, > Venkatesh.Y > _______________________________________________ > riak-users mailing list > riak-users@lists.basho.com (mailto:riak-users@lists.basho.com) > http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com _______________________________________________ riak-users mailing list riak-users@lists.basho.com http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com