relativity is search engine for ruby_on_rails applications. It uses a NoSQL Key-Value store to create searchable records. It is a modified copy of the data stored in your main database (MySQL, etc). It is read-only (not for storage and editing).
item.rb
class Item << ActiveRecord:Base
relativity_search_records do
string :name
end
end
irb:
Item.create!({:name => "Test Item", :properties => {:height => "6 feet", :width => "24 inches"}}) Item.search_by_key(:height, "6 feet") # [ Item(1) ] Item.search_by_key(:properties, {:height => "6 feet", :width => "24 inches"}) # [ Item(1) ]
ruby >= 1.9.2 rails >= 3.x MongoDB
1) Put it in your Gemfile and run ‘bundle install`
OR `gem install relativity`
2) rails generate relativity:install
In your ActiveRecord model, set the search_keys method:
class Item < ActiveRecord:Base search_keys do string :name end end
Then you can search via the class method ‘search_by_key`.
This is a search key-value store, and is in no way a datastore. It is purely for search records (it modifies some values for easier search.