Riak: Create index on key via Java/Scala -


i have bucket on riak in store simple timestamp -> string values in way:

val riakclient = riakfactory.newclient(myhttpclusterconfig) val mybucket = riakclient.fetchbucket(name).execute mybucket.store(timestamp.tostring, value).withoutfetch().w(1).execute 

what need add index on keys. tried defining java pojo in way:

public class mywrapper {     @riakindex(name="timestamp_index")     @riakkey     public string timestamp;     public string value;      public mywrapper(string timestamp, string value) {         this.timestamp = timestamp;         this.value = value;     } } 

and running

mybucket.store(new mywrapper(timestamp.tostring, value)).withoutfetch().w(1).execute 

the problem of approach in riak actual value stored json object:

{"value":"myvalue"} 

while need store myvalue string. there way achieve this? can't see index(name) method when executing store, , can't see annotations @riakkey values.

you can create riakobject using riakobjectbuilder, , add index on that:

val obj = riakobjectbuilder.newbuilder(bucketname, mykey)       .withvalue(myvalue)       .addindex("timestamp_index", timestamp)       .build mybucket.store(obj).execute 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -