Its rather simple question about how to list bucket keys using riak and I am using java-riak-client v1.1.4 and Riak 1.3.2 , there are few ways to do so that I know of:
-> Though Deprecated,
val riak = new RiakClient("http://localhost:8098/riak");
val r = riak.listBucket("bucket");
if (r.isSuccess()) {
val info = r.getBucketInfo();
val keys = info.getKeys(); // list of all object keys in this bucket
}
-> Using map reduce to get all records from a bucket, but for some reason doing map-reduce actually causes some Riak errors see Error , though the error isn't actually caused because of map-reduce.The code I have been using is given below, but the problem is this piece of code gives error only in case of two buckets, retrieve all using map reduce works properly for other buckets.
val riakClient = RiakFactory.httpClient
val result = riakClient.mapReduce(BUCKET_NAME_USER)
.addMapPhase(new NamedJSFunction("Riak.mapValuesJson"), true)
.execute //Gives errors
Now is there another way to retrieve bucket content using java-riak-client, or at least how to list bucket keys??