An active record connector to blur.
Ruby JavaScript
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

Active Blur

Active Blur is an Active Record extension library to enable creating indexes, updating indexes and searching indexes in Blur. The Active Record model objects that are configured to use this gem will automatically create tables in Blur, re-index upon updates in Blur, and allow searching (fielded and full text) in Blur.


To install the Active Blur gem in your Rails 3 app, add the following line to your Gemfile

gem 'active_blur'

Add configuration to environment

config.active_blur.connection_str = "blur-host:40010"
config.active_blur.options = {:cluster=>'cluster1',:table_uri_base=>'hdfs://blur-host:9000/blur/tables/'}

Setting Up Objects

Add a searchable block to the objects you wish to index.

class Book < ActiveRecord::Base

There are some options that can be passed into the searchable method. These options can also be set for all searchable models in config.

class Book < ActiveRecord::Base
	# Global options with defaults
	searchable {
		:full_text_index => true,
		:default_analyzer => :standard,
		:full_text_analyzer => :standard

Run the rake task to create the Blur table.

rake blur:create_table MODEL=Book

Searching Objects

# Fielded search"", options)

# Full text search"+Smith", options)

#Common options with their defaults
options = {:start => 0, #used for paging
           :fetch => 10, #how many results to return
           :user_context => nil, #identifier of the current user
           :score_type => :super #options include [:super, :aggregate, :best, :constant]

Re-indexing Objects

To re-index your model from scratch run the following rake task:

rake blur:reindex MODEL=Book


There are some pre-configured analyzers that can be used by setting the option to one of the following symbols:

  • :standard - uses org.apache.lucene.analysis.standard.StandardAnalyzer
  • :keyword - uses org.apache.lucene.analysis.KeywordAnalyzer
  • :simple - uses org.apache.lucene.analysis.SimpleAnalyzer
  • :stop - uses org.apache.lucene.analysis.StopAnalyzer
  • :whitespace - uses org.apache.lucene.analysis.WhitespaceAnalyzer

A string can also be used that is the full package/class name of the analyzer to use.

Upcoming Features

  • Searching associations
  • Faceting