picky 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -18,11 +18,10 @@ module Configuration
18
18
  #
19
19
  delegate :illegal_characters, :contract_expressions, :stopwords, :split_text_on, :normalize_words, :illegal_characters_after_splitting, :to => :default_index
20
20
 
21
- #
22
- #
23
21
  def type name, *fields
24
22
  types << Type.new(name, *fields)
25
23
  end
24
+ alias add_index type
26
25
  def field name, options = {}
27
26
  Field.new name, options
28
27
  end
@@ -8,21 +8,21 @@ class PickySearch < Application # The App Constant needs to be identical in appl
8
8
 
9
9
  # This is an example with books that you can adapt.
10
10
  #
11
- # Note: Much more is possible, but let's start out easy.
11
+ # Note: Much more is possible, but let's start out super easy.
12
12
  #
13
- # Ask me if you have questions!
13
+ # Ask me if you have questions or specific requests!
14
14
  #
15
15
 
16
16
  indexes do
17
- illegal_characters(/[^äöüa-zA-Z0-9\s\/\-\"\&\.]/)
18
- stopwords(/\b(und|der|die|das|mit|im|ein|des|dem|the|of)\b/)
17
+ illegal_characters(/[^a-zA-Z0-9\s\/\-\"\&\.]/)
18
+ stopwords(/\b(and|the|of|it|in|for)\b/)
19
19
  split_text_on(/[\s\/\-\"\&\.]/)
20
20
 
21
- type :books,
22
- Sources::DB.new('SELECT id, title, author, isbn13 as isbn FROM books', :file => 'app/db.yml'),
23
- field(:title, :qualifiers => [:t, :title, :titre], :similarity => Similarity::DoubleLevenshtone.new(3)), # Up to three similar title word indexed.
24
- field(:author, :qualifiers => [:s, :author, :auteur]),
25
- field(:isbn, :qualifiers => [:i, :isbn], :partial => Partial::None.new) # Partially searching on an ISBN makes not much sense.
21
+ add_index :books,
22
+ Sources::DB.new('SELECT id, title, author, isbn13 as isbn FROM books', :file => 'app/db.yml'),
23
+ field(:title, :similarity => Similarity::DoubleLevenshtone.new(3)), # Up to three similar title word indexed.
24
+ field(:author),
25
+ field(:isbn, :partial => Partial::None.new) # Partially searching on an ISBN makes not much sense.
26
26
  end
27
27
 
28
28
  queries do
@@ -30,16 +30,12 @@ class PickySearch < Application # The App Constant needs to be identical in appl
30
30
  # Note that Picky needs the following characters to
31
31
  # pass through, as they are control characters: *"~:
32
32
  #
33
- illegal_characters(/[^a-zA-Z0-9\s\/\-\,\&äöü\"\~\*\:]/)
34
- stopwords(/\b(und|der|die|das|mit|ein|des|dem|the|of)\b/)
33
+ illegal_characters(/[^a-zA-Z0-9\s\/\-\,\&\"\~\*\:]/)
34
+ stopwords(/\b(and|the|of|it|in|for)\b/)
35
35
  split_text_on(/[\s\/\-\,\&]+/)
36
36
 
37
- # Set some weights according to the position. Note that the order is important.
38
- #
39
- options = { :weights => Query::Weights.new([:title] => 6, [:author, :title] => 3) }
40
-
41
- route %r{^/books/full}, Query::Full.new(Indexes[:books], options)
42
- route %r{^/books/live}, Query::Live.new(Indexes[:books], options)
37
+ route %r{^/books/full}, Query::Full.new(Indexes[:books])
38
+ route %r{^/books/live}, Query::Live.new(Indexes[:books])
43
39
 
44
40
  root 200
45
41
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 7
9
- version: 0.0.7
8
+ - 8
9
+ version: 0.0.8
10
10
  platform: ruby
11
11
  authors:
12
12
  - Florian Hanke