Commit 40629dbf4fad1b3473ea608676a385f8c1180316

Authored by Andrew Kane
1 parent bba628b0

Improved documentation on stemming [skip ci]

Showing 1 changed file with 27 additions and 9 deletions   Show diff stats
README.md
... ... @@ -299,7 +299,9 @@ To only match the exact order, use:
299 299 User.search "fresh honey", match: :phrase
300 300 ```
301 301  
302   -### Language
  302 +### Language and Stemming
  303 +
  304 +Searchkick stems words by default for better matching. `tomatoes` and `tomato` both stem to `tomato`, so searches for either term will have the same matches.
303 305  
304 306 Searchkick defaults to English for stemming. To change this, use:
305 307  
... ... @@ -322,6 +324,30 @@ A few languages require plugins:
322 324 - `ukrainian` - [analysis-ukrainian plugin](https://www.elastic.co/guide/en/elasticsearch/plugins/7.4/analysis-ukrainian.html)
323 325 - `vietnamese` - [analysis-vietnamese plugin](https://github.com/duydo/elasticsearch-analysis-vietnamese)
324 326  
  327 +Disable stemming with:
  328 +
  329 +```ruby
  330 +class Image < ApplicationRecord
  331 + searchkick stem: false
  332 +end
  333 +```
  334 +
  335 +Specify certain words to be excluded from stemming: [unreleased]
  336 +
  337 +```ruby
  338 +class Image < ApplicationRecord
  339 + searchkick stem_exclusion: ["tomatoes"]
  340 +end
  341 +```
  342 +
  343 +Or change how words are stemmed: [unreleased]
  344 +
  345 +```ruby
  346 +class Image < ApplicationRecord
  347 + searchkick stemmer_override: ["tomatoes => other"]
  348 +end
  349 +```
  350 +
325 351 ### Synonyms
326 352  
327 353 ```ruby
... ... @@ -1858,14 +1884,6 @@ class Product &lt; ApplicationRecord
1858 1884 end
1859 1885 ```
1860 1886  
1861   -Turn off stemming
1862   -
1863   -```ruby
1864   -class Product < ApplicationRecord
1865   - searchkick stem: false
1866   -end
1867   -```
1868   -
1869 1887 Turn on stemming for conversions
1870 1888  
1871 1889 ```ruby
... ...