Example of how to add secondary index when storing object in Riak with Java Client? -


i storing hash-map in riak bucket this:

 bucket.store(key, dochashmap).execute(); 

i store object secondary index.

how accomplish this? aware iriakobject has addindex method, how access iriakobject before stored?

i think trying expected use-case, yet not able find documentation or examples on this. if can point me 1 appreciated.

thanks!

update:

@brian roach answered on riak mailing list , below. here custom class wrote extends hashmap:

class docmap extends hashmap<string, object> {     /**      * generated id      */     private static final long serialversionuid = 5807773481499313384l;      @riakindex(name="status") private string status;      public string getstatus() {         return status;     }      public void setstatus(string status) {         this.status = status;     } } 

i can still use object ordinary hashmap , store keys , values, write "status" secondary index (and end being called "status_bin" since it's string.

if you're passing in instance of core java hashmap ... can't.

the way default jsonconverter works metadata (such indexes) via annotations.

the object being passed in needs have field annotated @riakindex("index_name"). field can long/set<long> or string/set<string> (for _int , _bin indexes respectively).

these not converted json won't affect serialized data. can have multiple fields multiple indexes.

you don't have append "_int" or "_bin" index name in annotation - it's done automatically based on type.

easiest thing woud extend hashmap , add annotated field(s).


Comments

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -