4

Riak supports auto generated keys when storing an object:

http://wiki.basho.com/Basic-Riak-API-Operations.html:

Store a new object and assign random key #

If your application would rather leave key-generation up to Riak, issue a POST request to the bucket URL instead of a PUT to a bucket/key pair: POST /riak/bucket If you don’t pass Riak a “key” name after the bucket, it will know to create one for you.

is it possible to do the same when using the java client? it seems that key must be provided when storing an object.

Community
  • 1
  • 1
o'mac
  • 99
  • 5

1 Answers1

3

Edited to update: This is now available in the Java client. It was added in the 1.0.7 client release. See: https://github.com/basho/riak-java-client/pull/168


Unfortunately ... right now the Java client doesn't support this.

Someone has opened an issue for this: https://github.com/basho/riak-java-client/issues/141

I agree that it needs to be added. We've got a number of things we're working on at the moment for the Riak 1.2 release that are slightly higher priority, but I hope to work on this and get it added in the near future.

Brian Roach
  • 76,169
  • 12
  • 136
  • 161
  • Hey @Brian I see that you made this update but I'm still having issues getting this to work. Bucket bucket = this.myClient.fetchBucket(bucketName).execute(); bucket.store(POJO).withoutFetch().execute(); is throwing riak.client.convert.NoKeySpecifedException: null – KRB Jun 13 '13 at 17:08
  • Just a note, the above example is using the PB Client. – KRB Jun 13 '13 at 17:40
  • @KRB - I'm guessing I missed that in the JSON converter. I'll open an issue on it and fix it; sorry about that. – Brian Roach Jun 13 '13 at 21:51
  • See: https://github.com/basho/riak-java-client/issues/245 - I'll try to get to it in the next couple days. – Brian Roach Jun 13 '13 at 22:03
  • Thanks! I'll keep an eye out for it. – KRB Jun 14 '13 at 02:14