Guest User

Untitled

a guest
May 20th, 2018
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. ## Model code
  2. class Product
  3. define_index do
  4. indexes :name, :sortable => true
  5. indexes :description
  6. indexes manufacturer_name
  7. indexes merchant.name, :as => :merchant_name
  8. indexes category.name, :as => :category_name
  9. indexes price, :sortable => true
  10. end
  11. end
  12.  
  13. ## Results
  14. > Product.search("foo", :order => :name).map(&:name)
  15. # => ["100 Superstar Guitar Sounds On A Stompbox Budget", "21st Century Rock Buskers Book 2", "21st Century Rock Tab 2", "21st Century Rock Tab 3", "21st Century Rock: Play-Along Chord Songbook", "A Song's Best Friend: John Denver Remembered", "Akim-Foo the History of a Failure (Gold Coast 1873-74 Campaign)", "Best of Foo Fighters: Guitar Signature Licks", "Blade Dancer", "Buzz The Pop Quiz Solus", "Buzz! The Pop Quiz Bundle", "Buzz! The Pop Quiz Bundle - PlayStation 2", "Buzz! The Pop Quiz Solus - PlayStation 2", "CD - Art", "Cab Calloway - The Swing Era [Spanish Import]", "Cinema Of Vengeance", "Coheed And Cambria / No World For Tomorrow", "Coheed And Cambria / No World For Tomorrow", "Complete Music Foo Viola And Piano [Sacd/Cd Hybrid]", "Counting Crows / Saturday Nights And Sunday Mornings"]
  16. > Product.search("foo", :order => :category_name).map(&:name)
  17. # => []
Add Comment
Please, Sign In to add comment