@RiakIndex annotated field is not stored as part of value

Santi Kumar santi at veradocs.com
Mon Jan 26 11:48:59 EST 2015


Yes. I'm using POJO and annotating one of the field with RiakIndex. When
I'm reading the object with the key, as the tag field is not part of the
object, while writing I dont have the tag value while writing the object.

Class Foo {

private String fooId;

@RiakIndex(name="barid")

private String barid;

.....

}

When I'm storing the object, I set the barid for the object and storing the
object. Annotation is taking care of tagging the object with barid.

When I query the object with barId, I have the barId value so I'm setting
barId to object and writing it. But If I lookup the object with fooId, as
barId value is not part of the object I cant tag the object with barid. SO
when I'm writing the object I'm losing the association .

So Is there any thing I'm missing to make it part of the object state. That
way as you said, When I read-modify-write, the tag value exist all the time.


Thanks

Santi


On Jan 26, 2015 7:46 PM, "Christopher Meiklejohn" <cmeiklejohn at basho.com>
wrote:

>
> > On Jan 26, 2015, at 09:45, Santi Kumar <santi at veradocs.com> wrote:
> >
> > Hi
> > I'm defining a field of an object as 2i index with @RiakIndex. While
> creating the object I initialised both the values and stored the object
> against the key of that object and stored against the index.
> >
> > In a separate thread another field of the object is updated where I dont
> have handle to the 2i field. So I simply updated the field and stored back.
> As the 2i indexed field is not part of the object, that is gone as null and
> 2i index is removed from that object.
> >
> > After this, any search method on the original index key is failing to
> return this object. Is there any way to access 2i index corresponding to
> the key of object or storing the 2i index field as part of the object.
> >
> > When I fetch the object with the key, I'm not able to see the filed
> which is definied as 2i field?
> >
> > Please give me some clues on that.
>
> Hi Santi,
>
> When writing tags on objects for use with the 2i mechanism, it's required
> that you write all tags for the object each write; most client libraries
> will handle this if you perform a read-modify-write.  Does this help
> clarify?
>
> Thanks,
> Chris
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.basho.com/pipermail/riak-users_lists.basho.com/attachments/20150126/1decebcc/attachment-0002.html>


More information about the riak-users mailing list