Skip to content

Commit

Permalink
+ prototype project now much simpler
Browse files Browse the repository at this point in the history
  • Loading branch information
floere committed Oct 4, 2010
1 parent 312d022 commit 6fc62f9
Showing 1 changed file with 13 additions and 17 deletions.
30 changes: 13 additions & 17 deletions server/prototype_project/app/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,38 +8,34 @@ class PickySearch < Application # The App Constant needs to be identical in appl

# This is an example with books that you can adapt.
#
# Note: Much more is possible, but let's start out easy.
# Note: Much more is possible, but let's start out super easy.
#
# Ask me if you have questions!
# Ask me if you have questions or specific requests!
#

indexes do
illegal_characters(/[^äöüa-zA-Z0-9\s\/\-\"\&\.]/)
stopwords(/\b(und|der|die|das|mit|im|ein|des|dem|the|of)\b/)
illegal_characters(/[^a-zA-Z0-9\s\/\-\"\&\.]/)
stopwords(/\b(and|the|of|it|in|for)\b/)
split_text_on(/[\s\/\-\"\&\.]/)

type :books,
Sources::DB.new('SELECT id, title, author, isbn13 as isbn FROM books', :file => 'app/db.yml'),
field(:title, :qualifiers => [:t, :title, :titre], :similarity => Similarity::DoubleLevenshtone.new(3)), # Up to three similar title word indexed.
field(:author, :qualifiers => [:s, :author, :auteur]),
field(:isbn, :qualifiers => [:i, :isbn], :partial => Partial::None.new) # Partially searching on an ISBN makes not much sense.
add_index :books,
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.
end

queries do
maximum_tokens 5
# Note that Picky needs the following characters to
# pass through, as they are control characters: *"~:
#
illegal_characters(/[^a-zA-Z0-9\s\/\-\,\&äöü\"\~\*\:]/)
stopwords(/\b(und|der|die|das|mit|ein|des|dem|the|of)\b/)
illegal_characters(/[^a-zA-Z0-9\s\/\-\,\&\"\~\*\:]/)
stopwords(/\b(and|the|of|it|in|for)\b/)
split_text_on(/[\s\/\-\,\&]+/)

# Set some weights according to the position. Note that the order is important.
#
options = { :weights => Query::Weights.new([:title] => 6, [:author, :title] => 3) }

route %r{^/books/full}, Query::Full.new(Indexes[:books], options)
route %r{^/books/live}, Query::Live.new(Indexes[:books], options)
route %r{^/books/full}, Query::Full.new(Indexes[:books])
route %r{^/books/live}, Query::Live.new(Indexes[:books])

root 200
end
Expand Down

0 comments on commit 6fc62f9

Please sign in to comment.