Thanks,
   I tried the format you sent me earlier but when I tried to access the
args parameter inside the function, it is showing me the error:

{"inputs":['.$k.'],"query":[{"map":{"language":"javascript","source":"function(value,keydata,"arguments"){
var data = Riak.mapValuesJson(value)[0];
                      var obj = {};
                      obj[value.key] = {};
                      for(var i=1;i<3;i++)
                      {
                        var gender = \"G\"+ i;
                        obj[value.key][gender] = {};
                        for(var j=1;j<=6;j++)
                        {
                         var agegroup = \"A\" + j;
                         obj[value.key][gender][agegroup] = {};
                         obj[value.key][gender][agegroup][\"cpc_median\"] =
data[gender][j][agegroup][\"bid_estimations\"][0][\"cpc_median\"];
                         obj[value.key][gender][agegroup][\"users\"] =
data[gender][j][agegroup][\"users\"];

                        }
                      }
                      return [obj];

}","args":{"gender":"G0,G1","agegroups":"A0,A2","metrics":"users,cpc_median","groupby":"country"},"keep":true}}]}';


Please help me on the above.

To clarify my requirement, I would like to access the args parameter
(before keep parameter) inside javascript function and if possible I would
also like to know the flow that what is the need for args param after js
function.

Thanks,
Venkatesh.Y

On Wed, Jul 4, 2012 at 2:11 PM, Mathias Meyer <me...@paperplanes.de> wrote:

> Venki,
>
> You don't have to serialize the argument as a JSON string, it can simply
> be specified as a normal JSON data structure, just like the other data in
> the MapReduce request:
>
> curl -v -d '{"inputs":[["artists", "Beatles"]],
> "query":[{"map":{"language":"javascript","source":"function(v, k, a)
> {return [a];}","arg":{"paul": true}}}]}' -H "Content-Type:
> application/json" http://127.0.0.1:8098/mapred
>
> Cheers, Mathias
> http://riakhandbook.com
>
>
>
>
>
> On Wednesday, 4. July 2012 at 07:26, Venki Yedidha wrote:
>
> > Hi all,
> > I don't know why, I can't pass a json argument to map function.
> >
> >
> > "inputs":"[b1,k1],[b2,k2],[b3,k3]"
> >
> "query":[{map":{"language":"javascript","source":"function(value,keydata,args){}"
> >
> > for the args parameter I need to pass json of the form:
> > {\"name\":\"venkatesh\",\"age\":24}
> > (escaped " for json)
> > but it showing missing variable name..
> > On the other, If I am passing an array, it is not showing the error...
> > Please help me on the above.
> >
> > Thanks,
> > Venkatesh
> > _______________________________________________
> > 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

Reply via email to