Tuesday, September 4, 2012

Riak Search with Ripple in 3 easy steps

Modify your Riak app.config

By default, Riak Search is disabled. You can enable it in the app.config on each Riak server by changing the value from false to true. The config section should then look something like this:

%% Riak Search Config
 {riak_search, [
                %% To enable Search functionality set this 'true'.
                {enabled, true}
               ]},

Don't forget to restart Riak afterwards.

Enable the commit hook

From the Rails console you can enable the commit hook for the model you would like to make searchable. Keep in mind anything created prior to doing this will not be searchable. You will need to go back afterwards and essentially touch each of those objects.

MyObject.bucket.enable_index!
Just replace MyObject with class you wish to make searchable.

Search!

Ripple.client.search MyObject.bucket.name, "some_field:query"

For additional information, refer to these sites:

http://djds4rce.wordpress.com/2012/03/22/riak-fulll-text-search-with-ripple/ 

 

5 comments:

  1. Matt, are you able to execute searches in test mode? I have search working in the rails console in development mode, but test mode fails.

    ReplyDelete
    Replies
    1. Yes, but I ripped out the Test Riak server setup that was there and setup a separate test cluster.

      I actually have some rake tests for generating the config and joining the nodes that I need to share. Look for those soon!

      Delete
  2. Hey Mat thanks for the link back :)

    ReplyDelete
    Replies
    1. No problem, thanks for writing up a nice post about Riak Search. It's tough to find good info on it. I'm actually writing a gem to wrap up the search functionality. I already have some good baseline functionality built in. Check it out! Would love to hear your thoughts on it.

      https://github.com/validas/Ripplr

      Delete
    2. That seems awesome, but i no longer use raik, I will definitely check this out when I use riak again. cheers

      Delete