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/