Sha256: 32bab7ef5ea43934270edbe4a9c03aafb01ad9f9e3ed713a512610fc7331bdea

Contents?: true

Size: 1.49 KB

Versions: 2

Compression:

Stored size: 1.49 KB

Contents

# encoding: utf-8
#
# TODO Adapt the generated example
#      (a library books finder) to what you need.
#
# Questions? Mail me, IRC #picky, the google group, http://github.com/floere/picky/wiki.
#
class PickySearch < Application

  # How text is indexed.
  #
  default_indexing removes_characters: /[^a-zA-Z0-9\s\/\-\"\&\.]/,
                   stopwords:          /\b(and|the|of|it|in|for)\b/,
                   splits_text_on:     /[\s\/\-\"\&\.]/

  # How query text is preprocessed.
  #
  default_querying removes_characters: /[^a-zA-Z0-9\s\/\-\,\&\"\~\*\:]/, # Picky needs control chars *"~: to pass through.
                   stopwords:          /\b(and|the|of|it|in|for)\b/,
                   splits_text_on:     /[\s\/\-\,\&]+/,
                   maximum_tokens: 5, # Amount of tokens used in a search (5 = default).
                   substitutes_characters_with: CharacterSubstituters::WestEuropean.new # Normalizes special user input, Ä -> Ae, ñ -> n etc.

  library_src = Sources::CSV.new :title, :author, :year, file: 'app/library.csv'
  books_index = Index::Memory.new :books, library_src do
    category :title,
             similarity: Similarity::DoubleMetaphone.new(3), # Default is no similarity.
             partial: Partial::Substring.new(from: 1) # Default is from: -3.
    category :author, partial: Partial::Substring.new(from: 1)
    category :year, partial: Partial::None.new
  end

  route %r{\A/books\Z} => Search.new(books_index, :weights => { [:title, :author] => +3, [:title] => +1 })

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
picky-generators-2.0.0 prototypes/server/unicorn/app/application.rb
picky-generators-2.0.0.pre3 prototypes/server/unicorn/app/application.rb