Sha256: 5704076dd0301f18503d2399b43d8ca74e64318b2c1259ef5685dab5d8cd18a5

Contents?: true

Size: 1.7 KB

Versions: 34

Compression:

Stored size: 1.7 KB

Contents

# encoding: utf-8
#
require File.expand_path '../logging', __FILE__

# 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 BookSearch < Picky::Application

  # So we don't have to write Picky::
  # in front of everything.
  #
  include Picky

  # How text is indexed. Move to Index block to make it index specific.
  #
  indexing removes_characters: /[^a-z0-9\s\/\-\_\:\"\&\.]/i,
           stopwords:          /\b(and|the|of|it|in|for)\b/i,
           splits_text_on:     /[\s\/\-\_\:\"\&\/]/

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

  books_index = Index.new :books do
    source   Sources::CSV.new(:title, :author, :year, file: "data/#{PICKY_ENVIRONMENT}/library.csv")
    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

  books = Search.new books_index do
    boost [:title, :author] => +3,
          [:title] => +1
  end

  route %r{\A/books\Z} => books

end

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
picky-generators-3.2.0 prototypes/server/classic/app/application.rb
picky-generators-3.1.13 prototypes/server/classic/app/application.rb
picky-generators-3.1.12 prototypes/server/classic/app/application.rb
picky-generators-3.1.11 prototypes/server/classic/app/application.rb
picky-generators-3.1.10 prototypes/server/classic/app/application.rb
picky-generators-3.1.9 prototypes/server/classic/app/application.rb
picky-generators-3.1.8 prototypes/server/classic/app/application.rb
picky-generators-3.1.7 prototypes/server/classic/app/application.rb
picky-generators-3.1.6 prototypes/server/classic/app/application.rb
picky-generators-3.1.5 prototypes/server/classic/app/application.rb
picky-generators-3.1.4 prototypes/server/classic/app/application.rb
picky-generators-3.1.3 prototypes/server/classic/app/application.rb
picky-generators-3.1.2 prototypes/server/classic/app/application.rb
picky-generators-3.1.1 prototypes/server/classic/app/application.rb