Hello there,
The
core functionality works; the main thing to add now would be support
for has-one, has-many, belongs-to (and potentially
has-and-belongs-to-many) relationships. To model these relationships in
Riak, I can think of three ways to model this in Riak:
1.
Only use a `belongs_to` field on the inner data structure (so if a
Message belongs to a User, it contains a `user_id`. We might then search
for it using Solr.
2. Use the 'links' feature to create a
bidirectional link (still have a `user_id` on the Message, but also
`message_ids` in the links metadata)
3. Use an actual field (of type Set) in the outer Map CRDT containing references to all nested structures ('User.message_ids').
(1)
might be the most simple and natural to use, but the fact that we have
to wait approximately a second before Solr is able to see an
inserted/altered data structure is a deal breaker.
(2) on the
other hand might work fine for normal KV-values, but the documentation
is unclear on how to use Links or 2i (secondary indexes) on CRDTs (Riak
Data Types) instead of normal values.
So unless there is a better way to use (1) or (2), we're probably stuck with (3).
However,
there is another problem: In our current application that will be the
first consumer of the RiakEcto3-library, we store many 'Message'-objects
whose primary key (== the Riak key) is a Snowflake (so they are roughly
casually ordered). To allow people to paginate through these messages,
we'd therefore like to perform a range-based query on this primary ID:
Again, the fact that Solr takes a second before seeing the structures
might pose a problem here (and because we are using the primary key
anyway, using plain Riak, if possible, is probably a lot faster). Is
this possible from the get-go, or do we also need to add a 'secondary
index' for the 'primary index' to perform range-based queries? Are these
kinds of queries and indexes possible to use together with Riak Data
Types?
Thank you very much for your help!
~Wiebe-Marten / Qqwy