Search code examples
javariakriak-search

Java mapreduce and search for Riak


I saw the examples for Riak erlang and JS mapreduce. But I am a JAVA guy :), like to do it in JAVA. Moreover JS mapreduce is deprecated.

  1. Is there a way to do it in Java? Kindly give a sample.
  2. I was also looking for a Java sample of Riak 2.0 Search.

In Riak docs steps looks huge for riak-search. This might look like a small cookbook for mapreduce and search. Can it be summarized with actually steps with an example.

ISSUE

I tried the steps in github following is what i see :

   ./rebar get-deps
==> meck (get-deps)
==> protobuffs (get-deps)
==> hamcrest (get-deps)
==> riak_pb (get-deps)
==> riak-erlang-client (get-deps)
./rebar compile
==> meck (pre_compile)
==> meck (compile)
==> protobuffs (pre_compile)
==> protobuffs (compile)
==> hamcrest (pre_compile)
==> hamcrest (compile)
==> hamcrest (post_compile)
==> riak_pb (pre_compile)
==> riak_pb (compile)
==> riak-erlang-client (compile)
raghuveer@ubuntu:~/erlang-git/riak-erlang-client$ erl -pa $PATH_TO_RIAKC/ebin $PATH_TO_RIAKC/deps/*/ebin
Erlang/OTP 18 [erts-7.3] [source] [64-bit] [smp:4:4] [async-threads:10] [kernel-poll:false]

Eshell V7.3  (abort with ^G)
1> code:which(riakc_pb_socket).
non_existing

Solution

  • The map and reduce phase code must be either erlang or javascript. You can use java on the client side, but the mapreduce code needs to be executed in the Riak node, which uses erlang natively and has spidermonkey to run javascript.

    There are some pre-defined functions that might get you started at https://github.com/basho/riak_kv/blob/develop/src/riak_kv_mapreduce.erl

    The documentation contains examples of using java with search: https://docs.basho.com/riak/kv/2.1.4/developing/usage/search/