Re: Forming inputs to MR job
Take a look at this:https://gist.github.com/binarytemple/6bf84b041db0fabbdc74Specifically : Sample mapreduce job sectionFrom: Timur FayruzovSent: Wednay, December 30, 2015 8:01 PMTo: riak-usersSubject: Forming inputs to MR jobHello,I'm trying to write a simple MR job using _javascript_ and hit a wall right at start. I can't figure out how to specify "inputs". Here's the code:curl -XPOST "my_riak_server:8098/mapred" -H "Content-Type: application/json" -d @- <{ "input": "my_bucket" "query":[{ "map":{ "language":"_javascript_", "source":"function(riakObject, keydata, arg) { var m = riakObject.values[0].data; return [m]; }" } }]}EOFthis returns empty array.Aside: I know that listing all keys is slow but for now I can live with this.Note, that I'm using non-default bucket type, so the actual location of my keys is my_riak_server/types/my_bucket_type/buckets/my_bucket/my_key, but I can't figure out how to communicate this location properly in the "input" field. I have found this "documentation":https://github.com/basho/riak_kv/blob/2.1/src/riak_kv_mapred_json.erl#L101, but it does not explain how to specify bucket type and I'm not proficient enough in Erlang to follow the code easily. I did not find any other documentation on this field. Following returns all keys successfully, so data is there:curl 'http://my_riak_cluster:8098/types/my_bucket_type/buckets/my_bucket/keys?keys=true'Any pointers are highly appreciated.Thanks,Timur ___ riak-users mailing list riak-users@lists.basho.com http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com
Re: Forming inputs to MR job
Hi Timur, For your inputs line, try: "inputs":["mybucket_type", "mybucket"] Thanks, Alex On Wed, Dec 30, 2015 at 3:01 PM Timur Fayruzov wrote: > Hello, > > I'm trying to write a simple MR job using Javascript and hit a wall right > at start. I can't figure out how to specify "inputs". Here's the code: > curl -XPOST "my_riak_server:8098/mapred" -H "Content-Type: > application/json" -d @- < { > "input": "my_bucket" > "query":[{ > "map":{ > "language":"javascript", > "source":"function(riakObject, keydata, arg) { > var m = riakObject.values[0].data; > return [m]; > }" > } > }] > } > EOF > > this returns empty array. > > Aside: I know that listing all keys is slow but for now I can live with > this. > > Note, that I'm using non-default bucket type, so the actual location of my > keys is my_riak_server/types/my_bucket_type/buckets/my_bucket/my_key, but I > can't figure out how to communicate this location properly in the "input" > field. I have found this "documentation": > https://github.com/basho/riak_kv/blob/2.1/src/riak_kv_mapred_json.erl#L101, > but it does not explain how to specify bucket type and I'm not proficient > enough in Erlang to follow the code easily. I did not find any other > documentation on this field. > > Following returns all keys successfully, so data is there: > curl ' > http://my_riak_cluster:8098/types/my_bucket_type/buckets/my_bucket/keys?keys=true > ' > > Any pointers are highly appreciated. > > Thanks, > Timur > ___ > riak-users mailing list > 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
Forming inputs to MR job
Hello, I'm trying to write a simple MR job using Javascript and hit a wall right at start. I can't figure out how to specify "inputs". Here's the code: curl -XPOST "my_riak_server:8098/mapred" -H "Content-Type: application/json" -d @-