diff --git a/CHANGELOG.md b/CHANGELOG.md index 2811ad0..55590df 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,8 @@ - `and` now matches `&` - Added `transpositions` option to misspellings - Added `boost_mode` and `log` options to `boost_by` +- Added `prefix_length` option to `misspellings` +- Added ability to set env ## 0.9.0 diff --git a/README.md b/README.md index 441a47d..e7a4303 100644 --- a/README.md +++ b/README.md @@ -290,18 +290,6 @@ Product.search "mikl", misspellings: {transpositions: true} # milk This is planned to be the default in Searchkick 1.0. -For short queries, it may be helpful to turn on mispellings after a specified number of letters. - -```ruby -Product.search "api", misspellings: {prefix_length:2} # api, apt, not any -``` - -**Note:** If query length is the same as `prefix_length`, misspellings is automatically turned off. - -```ruby -Product.search "ah", misspellings: {prefix_length:2} # ah, not aha -``` - ### Indexing 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 rake searchkick:reindex:all ``` +Turn on misspellings after a certain number of characters + +```ruby +Product.search "api", misspellings: {prefix_length: 2} # api, apt, no ahi +``` + +**Note:** With this option, if the query length is the same as `prefix_length`, misspellings are turned off + +```ruby +Product.search "ah", misspellings: {prefix_length: 2} # ah, no aha +``` + ## Large Data Sets 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. diff --git a/test/sql_test.rb b/test/sql_test.rb index 3845798..635b9a5 100644 --- a/test/sql_test.rb +++ b/test/sql_test.rb @@ -245,7 +245,7 @@ class TestSql < Minitest::Test end def test_misspellings_prefix_length - store_names ["ap", "api", "apt", "any", "nap", "ah", "aha"] + store_names ["ap", "api", "apt", "any", "nap", "ah", "ahi"] assert_search "ap", ["ap"], misspellings: {prefix_length: 2} assert_search "api", ["ap", "api", "apt"], misspellings: {prefix_length: 2} end -- libgit2 0.21.0