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