diff --git a/CHANGELOG.md b/CHANGELOG.md index 0f3376d..f6a6c1a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ## 0.5.1 [unreleased] - Replaced stop words with common terms query +- Added language option - Fixed bug with empty array in where clause ## 0.5.0 diff --git a/README.md b/README.md index 8f69511..baf6e12 100644 --- a/README.md +++ b/README.md @@ -176,6 +176,18 @@ Available options are: :text_end ``` +### Language [master] + +Searchkick defaults to English for stemming. To change this, use: + +```ruby +class Product < ActiveRecord::Base + searchkick language: "German" +end +``` + +[See the list of languages](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/analysis-snowball-tokenfilter.html) + ### Synonyms ```ruby diff --git a/lib/searchkick/reindex.rb b/lib/searchkick/reindex.rb index e147528..687cac9 100644 --- a/lib/searchkick/reindex.rb +++ b/lib/searchkick/reindex.rb @@ -94,24 +94,24 @@ module Searchkick searchkick_keyword: { type: "custom", tokenizer: "keyword", - filter: ["lowercase", "snowball"] + filter: ["lowercase", "searchkick_stemmer"] }, default_index: { type: "custom", tokenizer: "standard", # synonym should come last, after stemming and shingle - # shingle must come before snowball - filter: ["standard", "lowercase", "asciifolding", "searchkick_index_shingle", "snowball"] + # shingle must come before searchkick_stemmer + filter: ["standard", "lowercase", "asciifolding", "searchkick_index_shingle", "searchkick_stemmer"] }, searchkick_search: { type: "custom", tokenizer: "standard", - filter: ["standard", "lowercase", "asciifolding", "searchkick_search_shingle", "snowball"] + filter: ["standard", "lowercase", "asciifolding", "searchkick_search_shingle", "searchkick_stemmer"] }, searchkick_search2: { type: "custom", tokenizer: "standard", - filter: ["standard", "lowercase", "asciifolding", "snowball"] + filter: ["standard", "lowercase", "asciifolding", "searchkick_stemmer"] }, # https://github.com/leschenko/elasticsearch_autocomplete/blob/master/lib/elasticsearch_autocomplete/analyzers.rb searchkick_autocomplete_index: { @@ -190,6 +190,10 @@ module Searchkick type: "nGram", min_gram: 1, max_gram: 50 + }, + searchkick_stemmer: { + type: "snowball", + language: options[:language] || "English" } }, tokenizer: { -- libgit2 0.21.0