I'm still getting a feel for schema design in Riak. I need to fetch
blog entries using a compound index of (author, tag).
This is what I've come up with.
I have two buckets:
/riak/entry/{id}
/riak/entries_by_author_and_tag/{author_id}.{tag}
Assume the keys are url safe.
Stored in entries_by_author_and_tag is a document that is just a JSON
document that is:
{
author_id: string,
tag: string,
entry_keys: {
entry_key: {pub_dt: iso8601zulu_string},
...
}
}
When I need to locate entries by a list of [(author_id, tag)] I map
the entries_by_author_and_tag documents to a list of {entry_key:"",
pub_dt:""} objects and then sort and limit them in the reduce phase.
This works, but it feel really dirty to me. Is this just plain dumb?
It feels dumb.
At first I figured I would just store the {author_id}.{tag} keys as a
author_tag_list in the entry and user Riak Search to fetch them but
because a user could follow hundreds or thousands of author/tag pairs,
the query string to fetch those entries would get too large. I assume
that looking up a 1000 entries_by_author_tag documents could be too
slow, I'll have to test that out.
Thanks,
Eric.
_______________________________________________
riak-users mailing list
[email protected]
http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com