searchkick 0.2.5 → 0.2.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +14 -6
- data/lib/searchkick/search.rb +11 -6
- data/lib/searchkick/version.rb +1 -1
- data/test/sql_test.rb +5 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e401e21d2d4ea7d82ec4295c01d62fca206efd5a
|
4
|
+
data.tar.gz: 85bbde0041479b1e5f102fbab24c73614d02cd79
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ecef9c2bfa8db0e3715c19a8b9bcf72206d8c0fd3a3d82dc1a9fb40e801a1dd158ecf3aaf8e9dad832d5c7b0331e4ab3596fdab134bc92dd429d015c5c60557b
|
7
|
+
data.tar.gz: 2fcff5e66e5c5e4e66a9a3cf150f3a9f386ef232098a69f4ec3d58d6d3ef5e599d7c651579937721cfe66e8edda93d2d438dd86bfbc76056df8c9e7624ed853c
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -145,6 +145,14 @@ end
|
|
145
145
|
|
146
146
|
Call `Product.reindex` after changing synonyms.
|
147
147
|
|
148
|
+
### Misspellings
|
149
|
+
|
150
|
+
By default, Searchkick handles misspelled queries by returning results with an [edit distance](http://en.wikipedia.org/wiki/Levenshtein_distance) of one. To turn off this feature, use:
|
151
|
+
|
152
|
+
```ruby
|
153
|
+
Product.search "zuchini", misspellings: false
|
154
|
+
```
|
155
|
+
|
148
156
|
### Indexing
|
149
157
|
|
150
158
|
Control what data is indexed with the `search_data` method. Call `Product.reindex` after changing this method.
|
@@ -277,7 +285,7 @@ First, add a controller action.
|
|
277
285
|
class CitiesController < ApplicationController
|
278
286
|
|
279
287
|
def autocomplete
|
280
|
-
render json: City.search(params[:
|
288
|
+
render json: City.search(params[:query], autocomplete: true, limit: 10).map(&:name)
|
281
289
|
end
|
282
290
|
|
283
291
|
end
|
@@ -286,14 +294,14 @@ end
|
|
286
294
|
Then add the search box and Javascript code to a view.
|
287
295
|
|
288
296
|
```html
|
289
|
-
<input type="text" id="
|
297
|
+
<input type="text" id="query" name="query" />
|
290
298
|
|
291
|
-
<script src="
|
292
|
-
<script src="
|
299
|
+
<script src="jquery.js"></script>
|
300
|
+
<script src="typeahead.js"></script>
|
293
301
|
<script>
|
294
|
-
$("#
|
302
|
+
$("#query").typeahead({
|
295
303
|
name: "city",
|
296
|
-
remote: "/cities/autocomplete?
|
304
|
+
remote: "/cities/autocomplete?query=%QUERY"
|
297
305
|
});
|
298
306
|
</script>
|
299
307
|
```
|
data/lib/searchkick/search.rb
CHANGED
@@ -64,14 +64,19 @@ module Searchkick
|
|
64
64
|
use_dis_max: false,
|
65
65
|
operator: operator
|
66
66
|
}
|
67
|
+
queries = [
|
68
|
+
{multi_match: shared_options.merge(boost: 10, analyzer: "searchkick_search")},
|
69
|
+
{multi_match: shared_options.merge(boost: 10, analyzer: "searchkick_search2")}
|
70
|
+
]
|
71
|
+
if options[:misspellings] != false
|
72
|
+
queries.concat [
|
73
|
+
{multi_match: shared_options.merge(fuzziness: 1, max_expansions: 3, analyzer: "searchkick_search")},
|
74
|
+
{multi_match: shared_options.merge(fuzziness: 1, max_expansions: 3, analyzer: "searchkick_search2")}
|
75
|
+
]
|
76
|
+
end
|
67
77
|
payload = {
|
68
78
|
dis_max: {
|
69
|
-
queries:
|
70
|
-
{multi_match: shared_options.merge(boost: 10, analyzer: "searchkick_search")},
|
71
|
-
{multi_match: shared_options.merge(boost: 10, analyzer: "searchkick_search2")},
|
72
|
-
{multi_match: shared_options.merge(fuzziness: 1, max_expansions: 3, analyzer: "searchkick_search")},
|
73
|
-
{multi_match: shared_options.merge(fuzziness: 1, max_expansions: 3, analyzer: "searchkick_search2")}
|
74
|
-
]
|
79
|
+
queries: queries
|
75
80
|
}
|
76
81
|
}
|
77
82
|
end
|
data/lib/searchkick/version.rb
CHANGED
data/test/sql_test.rb
CHANGED
@@ -105,6 +105,11 @@ class TestSql < Minitest::Unit::TestCase
|
|
105
105
|
assert_search "fresh honey", ["Honey"], partial: true
|
106
106
|
end
|
107
107
|
|
108
|
+
def test_misspellings
|
109
|
+
store_names ["abc", "abd", "aee"]
|
110
|
+
assert_search "abc", ["abc"], misspellings: false
|
111
|
+
end
|
112
|
+
|
108
113
|
def test_fields
|
109
114
|
store [
|
110
115
|
{name: "red", color: "light blue"},
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: searchkick
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Kane
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-09-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: tire
|