Hi Chris, Thank you for the prompt reply. Although that is exactly what I do. I've noticed that bucket can now be both binary or a tuple {binary, binary} where the first element is bucket type and the second is bucket. And it works for put/get operations and for mapred_bucket which traverses the whole bucket. But what I am trying to achieve is traverse only specified keys and that doesn't seem to work for mapred queiries. Here are the commands that work: simple get: riakc_pb_socket:get(Pid,{<<"bucket_type">>,<<"bucket">>},<<key>>). mapred over the whole bucket: riakc_pb_socket:mapred_bucket(Pid, {<<"bucket_type">>,<<"bucket">>}, [{map, {modfun, rc_mapred, map_kv_pairs}, none, true}]). but this one fails with the result {ok,[{0,[{error,notfound}]}]}: riakc_pb_socket:mapred(Pid, [{{<<"bucket_type">>,<<"bucket">>},<<key>>}],[{map, {modfun, rc_mapred, map_kv_pairs}, none, true}]).
If you can run a mapred query over specified keys could you please show me an example? Thanks, Michael On Thu Feb 05 2015 at 10:16:32 PM Christopher Meiklejohn < cmeiklej...@basho.com> wrote: > > > On Feb 5, 2015, at 10:55 AM, Mikhail Pustovalov <mpustova...@gmail.com> > wrote: > > > > Hello, > > I am using MapReduce just as a way to get multiple keys in one query (I > couldn't find a better way). My code used to work with Riak v.1.4 but now > when I try to run it against the latest version (2.0.4) mapred queries > return {error, notfound} for each key supplied. > > I have created a bucket type, put my keys inside a bucket in that type. > Simple 'put' and 'get' work fine. This line returns requested object: > > riakc_pb_socket:get(Pid,{<<"avs_n2">>,<<"avatars">>},<< > 145,3,100,41,46>>). > > This line though: > > riakc_pb_socket:mapred(Pid, > > [{{<<"avs_n2">>,<<"avatars">>},<<145,3,100,41,46>>}],[{map, > {modfun, rc_mapred, map_kv_pairs}, none, true}]). > > returns this: > > {ok,[{0,[{error,notfound}]}]} > > Seems like mapred functions are unable to query using bucket types. > Without bucket types everything still works fine. > > Also mapred_bucket over a whole bucket also works fine. > > Please, advise. Is it possible to use mapred with newly introduced > bucket types when I want only specific keys and not the full scan of a > bucket? > > Hi Mikhail, > > You’ll need to specify the bucket type as part of the bucket name when > performing the map reduce, for example, for inputs for the “maps” bucket > type and “users” bucket, you should use {<<“maps”>>, <<“users”>>} as the > bucket name for riakc_pb_socket. > > Thanks, > - Chris > > Christopher Meiklejohn > Senior Software Engineer > Basho Technologies, Inc. > cmeiklej...@basho.com
_______________________________________________ riak-users mailing list riak-users@lists.basho.com http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com