Commit 471ec8aaead4c5aa1c6f26c212d723dd3f1ceb6a

Authored by Andrew Kane
1 parent 17ed24fd

Added language option - closes #115

CHANGELOG.md
1 1 ## 0.5.1 [unreleased]
2 2  
3 3 - Replaced stop words with common terms query
  4 +- Added language option
4 5 - Fixed bug with empty array in where clause
5 6  
6 7 ## 0.5.0
... ...
README.md
... ... @@ -176,6 +176,18 @@ Available options are:
176 176 :text_end
177 177 ```
178 178  
  179 +### Language [master]
  180 +
  181 +Searchkick defaults to English for stemming. To change this, use:
  182 +
  183 +```ruby
  184 +class Product < ActiveRecord::Base
  185 + searchkick language: "German"
  186 +end
  187 +```
  188 +
  189 +[See the list of languages](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/analysis-snowball-tokenfilter.html)
  190 +
179 191 ### Synonyms
180 192  
181 193 ```ruby
... ...
lib/searchkick/reindex.rb
... ... @@ -94,24 +94,24 @@ module Searchkick
94 94 searchkick_keyword: {
95 95 type: "custom",
96 96 tokenizer: "keyword",
97   - filter: ["lowercase", "snowball"]
  97 + filter: ["lowercase", "searchkick_stemmer"]
98 98 },
99 99 default_index: {
100 100 type: "custom",
101 101 tokenizer: "standard",
102 102 # synonym should come last, after stemming and shingle
103   - # shingle must come before snowball
104   - filter: ["standard", "lowercase", "asciifolding", "searchkick_index_shingle", "snowball"]
  103 + # shingle must come before searchkick_stemmer
  104 + filter: ["standard", "lowercase", "asciifolding", "searchkick_index_shingle", "searchkick_stemmer"]
105 105 },
106 106 searchkick_search: {
107 107 type: "custom",
108 108 tokenizer: "standard",
109   - filter: ["standard", "lowercase", "asciifolding", "searchkick_search_shingle", "snowball"]
  109 + filter: ["standard", "lowercase", "asciifolding", "searchkick_search_shingle", "searchkick_stemmer"]
110 110 },
111 111 searchkick_search2: {
112 112 type: "custom",
113 113 tokenizer: "standard",
114   - filter: ["standard", "lowercase", "asciifolding", "snowball"]
  114 + filter: ["standard", "lowercase", "asciifolding", "searchkick_stemmer"]
115 115 },
116 116 # https://github.com/leschenko/elasticsearch_autocomplete/blob/master/lib/elasticsearch_autocomplete/analyzers.rb
117 117 searchkick_autocomplete_index: {
... ... @@ -190,6 +190,10 @@ module Searchkick
190 190 type: "nGram",
191 191 min_gram: 1,
192 192 max_gram: 50
  193 + },
  194 + searchkick_stemmer: {
  195 + type: "snowball",
  196 + language: options[:language] || "English"
193 197 }
194 198 },
195 199 tokenizer: {
... ...