Eric Redmond – Distributed Search on Riak 2.0
Riak excels at one type of query: key puts and key gets. But the world demands more from a database. Since Basho isn't primarily a search company, we decided to leverage the power of Solr for Riak 2.0. This is a walkthrough of what new features we added, how works, and why you'd want to use it. Also, of course, live demos.
4. riak.conf
## The enabled Search set this 'on'.
search = off
!
## The port number which Solr binds to.
search.solr_port = 10014
!
## The port number which Solr JMX binds to.
search.solr_jmx_port = 10013
!
## The arguments to pass to the Solr JVM. Non-standard
## arguments, i.e. -XX, may not be portable across JVM
## implementations. E.g. -XX:+UseCompressedStrings.
search.solr_jvm_args = -Xms1g -Xmx1g -XX:+UseStringCache -
XX:+UseCompressedOops
5. riak.conf
## The enabled Search set this 'on'.
search = on
!
## The port number which Solr binds to.
search.solr_port = 10014
!
## The port number which Solr JMX binds to.
search.solr_jmx_port = 10013
!
## The arguments to pass to the Solr JVM. Non-standard
## arguments, i.e. -XX, may not be portable across JVM
## implementations. E.g. -XX:+UseCompressedStrings.
search.solr_jvm_args = -Xms1g -Xmx1g -XX:+UseStringCache -
XX:+UseCompressedOops
6. riak-admin cluster join riak@10.0.0.2
... and so on...
riak-admin cluster plan
riak-admin cluster commit
7. riak-admin cluster join riak@10.0.0.2
... and so on...
riak-admin cluster plan
riak-admin cluster commit
riak-admin security add-user eric 12345
riak-admin security add-user admin 123456
riak-admin security grant search.query
ON index simple TO any
riak-admin security grant search.admin
ON schema TO admin
8. require 'riak'
client = Riak::Client.new
!
# create index
client.create_search_index('simple')
!
# tie the index to bucket 'cats'
bucket = Riak::Bucket.new(client, 'cats')
bucket.props = { search_index: 'simple' }
37. Permissions
riak-admin security grant search.admin ON schema TO admin
riak-admin security grant search.admin ON index TO admin
riak-admin security grant search.query ON index TO user
riak-admin security grant search.query ON index wiki TO user