0

How to List all Keys from a Riak KV Bucket?

I am a getting a Response using the rest API,

http://localhost:8098/buckets/bucket_name/keys?keys=true

but not with the Java client.

1 Answer 1

1

First off I would caution that listing keys is an expensive operation and should not be done on a production cluster. That said please check out the Java client documentation (the latest version can be found here: http://basho.github.io/riak-java-client/2.1.0/). Under com.basho.riak.client.api.commands.kv you will find the section on List Keys which has the following example:

Namespace ns = new Namespace("my_type", "my_bucket");
ListKeys lk = new ListKeys.Builder(ns).build();
ListKeys.Response response = client.execute(lk);
for (Location l : response)
{
     System.out.println(l.getKeyAsString());
}

There is also an example there that demonstrates how to stream the results back to the client.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.