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 <ul><li>Less flexibility on keys </li></ul><ul><li>Facets must be configured ahead of time </li></ul><ul><l...
Design Goals <ul><li>Work with any Ruby class representing data (model) </li></ul><ul><li>Keep search away from the data s...
How is it used <ul><li>Install the gem </li></ul><ul><li>Make sure you're class defines these methods </li></ul><ul><ul><l...
Example: CouchDB <ul><li># id is already implemented and so is get.  CouchRest has a method called keys which we'll use cl...
Example: ActiveRecord <ul><li># id is implemented in ActiveRecord already class   MyModel   < ActiveRecord::Base   include...
Issue a Search Call <ul><li>All models in result set (with facet) </li></ul><ul><ul><li>TanningBed.solr_search(@query, :fa...
Whats the result? <ul><li>result.data[&quot;docs&quot;] <= hash of ids </li></ul><ul><li>TanningBed.solr_load <= models </...
Is setting up Solr hard <ul><li>rake solr:start <- From TanningBed installed location </li></ul><ul><li>rake solr:start_te...
Tanning Bed in Action
Is It Complicated? <ul><li>LOC 142 </li></ul><ul><li>COMMENTS 29 </li></ul><ul><li>BLANK 32 </li></ul><ul><li>LINES 201 </...
Where <ul><li>http://github.com/notch8/tanning_bed </li></ul><ul><li>[email_address] </li></ul>
Upcoming SlideShare
Loading in …5
×

Tanning Bed

1,043 views

Published on

Published in: Health & Medicine, Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
1,043
On SlideShare
0
From Embeds
0
Number of Embeds
97
Actions
Shares
0
Downloads
5
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Tanning Bed

  1. 1. Tanning Bed by Rob Kaufman Notch8.com made possible by Assaydepot.com
  2. 2. Tanning Bed?
  3. 9. Why not acts_as_solr + it only works with Active Record
  4. 10. Why not Sphinx <ul><li>Less flexibility on keys </li></ul><ul><li>Facets must be configured ahead of time </li></ul><ul><li>Solr handles over the network use better </li></ul>
  5. 11. Design Goals <ul><li>Work with any Ruby class representing data (model) </li></ul><ul><li>Keep search away from the data store </li></ul><ul><li>Make it simple </li></ul><ul><li>Use the Solr Ruby bindings </li></ul>
  6. 12. How is it used <ul><li>Install the gem </li></ul><ul><li>Make sure you're class defines these methods </li></ul><ul><ul><li>id - unique identifier for the record </li></ul></ul><ul><ul><li>Class.get - this method receives and object's id and loads it </li></ul></ul><ul><ul><li>solr_keys - an array of method names, the method results will be added to the index </li></ul></ul><ul><li>Setup a save hook </li></ul>
  7. 13. Example: CouchDB <ul><li># 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 </li></ul>
  8. 14. Example: ActiveRecord <ul><li># 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 </li></ul>
  9. 15. Issue a Search Call <ul><li>All models in result set (with facet) </li></ul><ul><ul><li>TanningBed.solr_search(@query, :facets => {:fields => [:field_name_facet]}) </li></ul></ul><ul><li>One model only </li></ul><ul><ul><li>MyModel.solr_search(@query) </li></ul></ul>
  10. 16. Whats the result? <ul><li>result.data[&quot;docs&quot;] <= hash of ids </li></ul><ul><li>TanningBed.solr_load <= models </li></ul><ul><li>Facet Counts </li></ul><ul><ul><li>@search.data[&quot;facet_counts&quot;][&quot;facet_fields&quot;][&quot;field_name_facet&quot;] </li></ul></ul>
  11. 17. Is setting up Solr hard <ul><li>rake solr:start <- From TanningBed installed location </li></ul><ul><li>rake solr:start_testing </li></ul>
  12. 18. Tanning Bed in Action
  13. 19. Is It Complicated? <ul><li>LOC 142 </li></ul><ul><li>COMMENTS 29 </li></ul><ul><li>BLANK 32 </li></ul><ul><li>LINES 201 </li></ul>
  14. 20. Where <ul><li>http://github.com/notch8/tanning_bed </li></ul><ul><li>[email_address] </li></ul>

×