tanning bed

Download Tanning Bed

If you can't read please download the document

Upload: rob-kaufman

Post on 16-Apr-2017

1.071 views

Category:

Health & Medicine


0 download

TRANSCRIPT

Tanning Bed

by Rob KaufmanNotch8.commade possible byAssaydepot.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

Issue a Search Call

All models in result set (with facet)

TanningBed.solr_search(@query, :facets => {:fields => [:field_name_facet]})

One model only

MyModel.solr_search(@query)

Whats the result?

result.data["docs"]