Tanning Bed by Rob Kaufman Notch8.com made possible by Assaydepot.com
Tanning Bed?
Why not acts_as_solr + it only works with Active Record
Why not Sphinx
Less flexibility on keys
Facets must be configured ahead of time
Solr handles over the network use better
Design Goals
Work with any Ruby class representing data (model)
Keep search away from the data store
Make it simple
Use the Solr Ruby bindings
How is it used
Install the gem
Make sure you're class defines these methods
id - unique identifier for the record
Class.get - this method receives and object's id and loads it
solr_keys - an array of method names, the method results will be added to the index
Setup a save hook
Example: CouchDB
# id is already implemented and so is get. CouchRest has a method called keys which we'll use class MyDocument < CouchRest::Model include TanningBed key_accessor :name key_accessor :address def solr_keys keys end end
Example: ActiveRecord
# id is implemented in ActiveRecord already class MyModel < ActiveRecord::Base include TanningBed def get (value) find(value) end def solr_keys attribute_names end end
0 comments
Post a comment