Commit 6c2b1fb8312a9921ee65e31e8c141a5ecaae5e19

Authored by Andrew Kane
1 parent 432c3754

Cleaned up prefix_length option

Showing 3 changed files with 15 additions and 13 deletions   Show diff stats
CHANGELOG.md
... ... @@ -3,6 +3,8 @@
3 3 - `and` now matches `&`
4 4 - Added `transpositions` option to misspellings
5 5 - Added `boost_mode` and `log` options to `boost_by`
  6 +- Added `prefix_length` option to `misspellings`
  7 +- Added ability to set env
6 8  
7 9 ## 0.9.0
8 10  
... ...
README.md
... ... @@ -290,18 +290,6 @@ Product.search "mikl", misspellings: {transpositions: true} # milk
290 290  
291 291 This is planned to be the default in Searchkick 1.0.
292 292  
293   -For short queries, it may be helpful to turn on mispellings after a specified number of letters.
294   -
295   -```ruby
296   -Product.search "api", misspellings: {prefix_length:2} # api, apt, not any
297   -```
298   -
299   -**Note:** If query length is the same as `prefix_length`, misspellings is automatically turned off.
300   -
301   -```ruby
302   -Product.search "ah", misspellings: {prefix_length:2} # ah, not aha
303   -```
304   -
305 293 ### Indexing
306 294  
307 295 Control what data is indexed with the `search_data` method. Call `Product.reindex` after changing this method.
... ... @@ -1021,6 +1009,18 @@ Reindex all models - Rails only
1021 1009 rake searchkick:reindex:all
1022 1010 ```
1023 1011  
  1012 +Turn on misspellings after a certain number of characters
  1013 +
  1014 +```ruby
  1015 +Product.search "api", misspellings: {prefix_length: 2} # api, apt, no ahi
  1016 +```
  1017 +
  1018 +**Note:** With this option, if the query length is the same as `prefix_length`, misspellings are turned off
  1019 +
  1020 +```ruby
  1021 +Product.search "ah", misspellings: {prefix_length: 2} # ah, no aha
  1022 +```
  1023 +
1024 1024 ## Large Data Sets
1025 1025  
1026 1026 For large data sets, check out [Keeping Elasticsearch in Sync](https://www.found.no/foundation/keeping-elasticsearch-in-sync/). Searchkick will make this easy in the future.
... ...
test/sql_test.rb
... ... @@ -245,7 +245,7 @@ class TestSql < Minitest::Test
245 245 end
246 246  
247 247 def test_misspellings_prefix_length
248   - store_names ["ap", "api", "apt", "any", "nap", "ah", "aha"]
  248 + store_names ["ap", "api", "apt", "any", "nap", "ah", "ahi"]
249 249 assert_search "ap", ["ap"], misspellings: {prefix_length: 2}
250 250 assert_search "api", ["ap", "api", "apt"], misspellings: {prefix_length: 2}
251 251 end
... ...