How to add a secondary index with the Java client

Kevin Burton rkevinburton at
Thu Apr 11 17:10:02 EDT 2013

The example uses RiakObjectBuilder. It adds the value with value.getBytes()
when value is a string. Why is this necessary? Also it specifically sets the
content type to "text/plain". Same question is this necessary? All of my
objects will be JSON serialized versions of instances of my classes. The
example adds an index. I am assuming that the first argument is the name of
the index and the second is the value? It isn't quite clear from the code.


Thanks for the tip.


From: Jeremiah Peschka [mailto:jeremiah.peschka at] 
Sent: Monday, April 08, 2013 4:31 PM
To: Kevin Burton
Cc: Jeff Peck; riak-users at
Subject: Re: How to add a secondary index with the Java client


You can find an example of saving indexes here:


Where result is IRiakObject, links can be added via (from the README
<> )


result.addLink(new RiakLink("otherBucket", "otherKey", "tag"));


Jeremiah Peschka - Founder, Brent Ozar Unlimited

MCITP: SQL Server 2008, MVP

Cloudera Certified Developer for Apache Hadoop


On Mon, Apr 8, 2013 at 2:20 PM, Kevin Burton <rkevinburton at>

I have the same question if you find an answer. I would also like to use a
Java client to add links.

On Apr 8, 2013, at 3:56 PM, Jeff Peck <jeffp at> wrote:

> Hello,
> I have been looking through the documentation for an example of how to add
a secondary index in Riak, using the Java client.
> I am currently storing my object (which is a HashMap) like this:
>, docHashMap).execute();
> What would I need to do to add an index to that object before it gets
> Thanks,
> Jeff
> _______________________________________________
> riak-users mailing list
> riak-users at

riak-users mailing list
riak-users at


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the riak-users mailing list