Getting a list of events using secondary index

Alex Robson asrobson at gmail.com
Thu Oct 17 15:53:56 EDT 2013


Working on an event-sourcing aproach and would really appreciate some
advice.

1. Every event is tagged with a secondary index ("aggregate_id")
2. Every event's id is k-ordered (using a Flake compatible id generator)
3. Every aggregate has last_event_id

I would like the ability to select all event ids, for a given an
aggregate_id that occurred after the last_event_id for a given aggregate.

At the moment, I am using the secondary index only to get all event ids for
a particular aggregate. I then filter the id list so that I only have the
ids that occurred after last_event_id. I then issue a multi-key get and
retrieve the events I want.

Latency is fairly important in this case and so I wanted to see if there
were a better way (or if what I'm doing is just an awful misuse of Riak). I
got the impression from reading docs that map/reduce is not ideal for
real-time operations and intended more for batch stuff that runs out of
band. This series of operations would occur for every read of the aggregate.

Thanks for your help and thanks for Riak :)

Alex
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.basho.com/pipermail/riak-users_lists.basho.com/attachments/20131017/51547c62/attachment.html>


More information about the riak-users mailing list