Reputation: 19014
Consider a JSON object such as:
{
name: 'ben',
employer: 'The Sherwin-Williams Company',
emails: ['[email protected]', '[email protected]']
}
In MongoDB you can index the emails field such that you can find any object with '[email protected]' as an email. Is this possible in Riak? I couldn't tell from reading the docs.
Upvotes: 2
Views: 92
Reputation: 3465
You certainly can, but you have to manually enter the index entries.
Here's an example in Ruby:
require 'riak'
client = Riak::Client.new(:protocol => "pbc", :host => "127.0.0.1", :pb_port => 10047, :http_port => 10048)
ben = client['people'].get_or_new('ben')
ben.data = { :name => "ben",
:employer => "The Sherwin-Williams Company",
:emails => ['[email protected]', '[email protected]'] }
ben.indexes['email_bin'] << "[email protected]"
ben.indexes['email_bin'] << "[email protected]"
ben.store
Now you can look it up via the ruby library, or through your web browser at http://127.0.0.1:10018/buckets/people/index/email_bin/[email protected]
On my system this returns:
{"keys":["ben"]}
I know the Java and the Ruby Riak libraries support adding/editing index entries, I will have to check on the others and get back to you though.
Upvotes: 2