Skip to content

Navigation Menu

Sign up

Configuration Examples

floere edited this page Dec 16, 2011 · 6 revisions

Configuration Examples

Here are some of the many configurations.

Indexing

Default

 indexing removes_characters: /[^äöüa-zA-Z0-9\s\/\-\"\&\.]/i,
 stopwords: /\b(and|the|or|on|of|in|is|to|from|as|at|an)\b/i,
 splits_text_on: /[\s\/\-\"\&\/]/,
 removes_characters_after_splitting: /[\.]/,
 normalizes_words: [[/\$(\w+)/i, '1円 dollars']],
 rejects_token_if: lambda { |token| token.blank? || token == :hello },
 case_sensitive: false,
 substitutes_characters_with: CharacterSubstituters::WestEuropean.new

For a specific index

 Picky::Index.new(:special_indexing) do
 source { Book.order('title ASC') }
 indexing removes_characters: /[^äöüd-zD-Z0-9\s\/\-\"\&\.]/i, # a-c, A-C are removed
 splits_text_on: /[\s\/\-\"\&\/]/
 category :title,
 qualifiers: [:t, :title, :titre],
 partial: Partial::Substring.new(from: 1),
 similarity: Similarity::DoubleMetaphone.new(2)
 end

Searching

Default

querying removes_characters: /[^ïôåñëäöüa-zA-Z0-9\s\/\-,円\&\.\"\~\*\:]/i,
 stopwords: /\b(and|the|or|on|of|in|is|to|from|as|at|an)\b/i,
 splits_text_on: /[\s\/\-,円\&\/]/,
 removes_characters_after_splitting: //,
 case_sensitive: true,
 maximum_tokens: 5,
 substitutes_characters_with: CharacterSubstituters::WestEuropean.new

For a specific Search

Picky::Search.new books_index do
 searching removes_characters: /[buks]/i,
 stopwords: /\b(and|the|or|on|of|in|is|to|from|as|at|an)\b/i
end

Index

Picky::Index.new(:books, result_identifier: 'Books') do
 source { Book.order('isbn ASC') }
 category :title,
 qualifiers: [:t, :title, :titre],
 partial: Partial::Substring.new(from: 1),
 similarity: Similarity::DoubleMetaphone.new(2)
 category :author,
 qualifiers: [:a, :author, :auteur],
 partial: Partial::Substring.new(from: -2)
 category :year,
 qualifiers: [:y, :year, :annee],
 partial: Partial::None.new
 category :publisher, qualifiers: [:p, :publisher]
 category :subjects, qualifiers: [:s, :subject]
end

Routing

See Sinatra.

Clone this wiki locally

AltStyle によって変換されたページ (->オリジナル) /