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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 81763af637b2e95a2eebbcecf303a23274b46221
4
- data.tar.gz: dee89361eb8976c550ad20f413fc8ca42c5a696b
3
+ metadata.gz: e401e21d2d4ea7d82ec4295c01d62fca206efd5a
4
+ data.tar.gz: 85bbde0041479b1e5f102fbab24c73614d02cd79
5
5
  SHA512:
6
- metadata.gz: bdf78091a6aa79ae75eed94e54b0f0e5c53e9515adfd4914e82b92882dfe4308af5d9cd1c4333586244f94eef69ef4c921ff53c77188f47cb1db16a4467b9087
7
- data.tar.gz: 18773058d6ba94a0f1b2da546e426884483f45c50428babd4e172178ad0804f219648fe5de97d82c55a723886cef4d9d39b053cedc0b2d5a66d0c1cf58b3edd3
6
+ metadata.gz: ecef9c2bfa8db0e3715c19a8b9bcf72206d8c0fd3a3d82dc1a9fb40e801a1dd158ecf3aaf8e9dad832d5c7b0331e4ab3596fdab134bc92dd429d015c5c60557b
7
+ data.tar.gz: 2fcff5e66e5c5e4e66a9a3cf150f3a9f386ef232098a69f4ec3d58d6d3ef5e599d7c651579937721cfe66e8edda93d2d438dd86bfbc76056df8c9e7624ed853c
@@ -1,3 +1,7 @@
1
+ ## 0.2.6
2
+
3
+ - Added option to disable misspellings
4
+
1
5
  ## 0.2.5
2
6
 
3
7
  - Added geospartial searches
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[:q], autocomplete: true, limit: 10).map(&:name)
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="q" name="q" />
297
+ <input type="text" id="query" name="query" />
290
298
 
291
- <script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
292
- <script src="//cdnjs.cloudflare.com/ajax/libs/typeahead.js/0.9.3/typeahead.min.js"></script>
299
+ <script src="jquery.js"></script>
300
+ <script src="typeahead.js"></script>
293
301
  <script>
294
- $("#q").typeahead({
302
+ $("#query").typeahead({
295
303
  name: "city",
296
- remote: "/cities/autocomplete?q=%QUERY"
304
+ remote: "/cities/autocomplete?query=%QUERY"
297
305
  });
298
306
  </script>
299
307
  ```
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Searchkick
2
- VERSION = "0.2.5"
2
+ VERSION = "0.2.6"
3
3
  end
@@ -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.5
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-08-30 00:00:00.000000000 Z
11
+ date: 2013-09-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tire