picky 0.0.7 → 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/picky/configuration/indexes.rb +1 -2
- data/prototype_project/app/application.rb +13 -17
- metadata +2 -2
@@ -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(/[
|
18
|
-
stopwords(/\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
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
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(
|
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
|
-
|
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
|