Guest User

Untitled

a guest
Jun 24th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. class PickySearch < Application # The App Constant needs to be identical in config.ru.
  2.  
  3. indexes.illegal_characters(/[^a-zA-Z0-9\s\/\-\"\&\.]/)
  4. indexes.stopwords(/\b(and|the|of|it|in|for)\b/)
  5. indexes.split_text_on(/[\s\/\-\"\&\.]/)
  6.  
  7. books_index = index Sources::DB.new('SELECT id, title, author, isbn13 as isbn FROM books', :file => 'app/db.yml'),
  8. field(:title, :similarity => Similarity::DoubleLevenshtone.new(3)), # Up to three similar title word indexed.
  9. field(:author),
  10. field(:isbn, :partial => Partial::None.new) # Partially searching on an ISBN makes not much sense.
  11.  
  12. # Note that Picky needs the following characters to
  13. # pass through, as they are control characters: *"~:
  14. #
  15. queries.illegal_characters(/[^a-zA-Z0-9\s\/\-\,\&\"\~\*\:]/)
  16. queries.stopwords(/\b(and|the|of|it|in|for)\b/)
  17. queries.split_text_on(/[\s\/\-\,\&]+/)
  18. queries.maximum_tokens 5
  19.  
  20. full = Query::Full.new books_index
  21. live = Query::Live.new books_index
  22.  
  23. http.route %r{^/books/full} => full
  24. http.route %r{^/books/live} => live
  25.  
  26. end
Add Comment
Please, Sign In to add comment