If you have m-r code in your application, codify those functions, store them separately in a directory or even Riak objects, and refer to them by name in your code. Or, better yet, write it in Erlang.
mapper = lambda x: (x['word'],1)
Or something of the the following flavor:
mapper = JSCode('function(x) {return (x.word,1)}')