Commit 5667c9544a8f1c294cf1cdf4f22e2bb0d613737f

Authored by Andrew
1 parent 67f40267

Added support for Vietnamese [skip ci]

1 ## 3.0.2 [unreleased] 1 ## 3.0.2 [unreleased]
2 2
3 -- Added support for Korean 3 +- Added support for Korean and Vietnamese
4 - Fixed `Unsupported argument type: Symbol` for async partial reindex 4 - Fixed `Unsupported argument type: Symbol` for async partial reindex
5 - Fixed infinite recursion with multi search and misspellings below 5 - Fixed infinite recursion with multi search and misspellings below
6 - Do not raise an error when `id` is indexed 6 - Do not raise an error when `id` is indexed
@@ -304,9 +304,10 @@ A few languages require plugins: @@ -304,9 +304,10 @@ A few languages require plugins:
304 304
305 - `chinese` - [elasticsearch-analysis-ik plugin](https://github.com/medcl/elasticsearch-analysis-ik) 305 - `chinese` - [elasticsearch-analysis-ik plugin](https://github.com/medcl/elasticsearch-analysis-ik)
306 - `japanese` - [analysis-kuromoji plugin](https://www.elastic.co/guide/en/elasticsearch/plugins/6.2/analysis-kuromoji.html) 306 - `japanese` - [analysis-kuromoji plugin](https://www.elastic.co/guide/en/elasticsearch/plugins/6.2/analysis-kuromoji.html)
307 -- `korean` - [elasticsearch-analysis-openkoreantext](https://github.com/open-korean-text/elasticsearch-analysis-openkoreantext) [master] 307 +- `korean` - [elasticsearch-analysis-openkoreantext plugin](https://github.com/open-korean-text/elasticsearch-analysis-openkoreantext) [master]
308 - `polish` - [analysis-stempel plugin](https://www.elastic.co/guide/en/elasticsearch/plugins/6.2/analysis-stempel.html) 308 - `polish` - [analysis-stempel plugin](https://www.elastic.co/guide/en/elasticsearch/plugins/6.2/analysis-stempel.html)
309 - `ukrainian` - [analysis-ukrainian plugin](https://www.elastic.co/guide/en/elasticsearch/plugins/6.2/analysis-ukrainian.html) 309 - `ukrainian` - [analysis-ukrainian plugin](https://www.elastic.co/guide/en/elasticsearch/plugins/6.2/analysis-ukrainian.html)
  310 +- `vietnamese` - [elasticsearch-analysis-vietnamese plugin](https://github.com/duydo/elasticsearch-analysis-vietnamese) [master]
310 311
311 ### Synonyms 312 ### Synonyms
312 313
lib/searchkick/index_options.rb
@@ -181,6 +181,18 @@ module Searchkick @@ -181,6 +181,18 @@ module Searchkick
181 type: "openkoreantext-analyzer" 181 type: "openkoreantext-analyzer"
182 } 182 }
183 ) 183 )
  184 + when "vietnamese"
  185 + settings[:analysis][:analyzer].merge!(
  186 + default_analyzer => {
  187 + type: "vi_analyzer"
  188 + },
  189 + searchkick_search: {
  190 + type: "vi_analyzer"
  191 + },
  192 + searchkick_search2: {
  193 + type: "vi_analyzer"
  194 + }
  195 + )
184 when "polish", "ukrainian", "smartcn" 196 when "polish", "ukrainian", "smartcn"
185 settings[:analysis][:analyzer].merge!( 197 settings[:analysis][:analyzer].merge!(
186 default_analyzer => { 198 default_analyzer => {
lib/searchkick/query.rb
@@ -317,7 +317,7 @@ module Searchkick @@ -317,7 +317,7 @@ module Searchkick
317 qs << shared_options.merge(analyzer: "searchkick_search") 317 qs << shared_options.merge(analyzer: "searchkick_search")
318 318
319 # searchkick_search and searchkick_search2 are the same for ukrainian 319 # searchkick_search and searchkick_search2 are the same for ukrainian
320 - unless %w(japanese korean polish ukrainian).include?(searchkick_options[:language]) 320 + unless %w(japanese korean polish ukrainian vietnamese).include?(searchkick_options[:language])
321 qs << shared_options.merge(analyzer: "searchkick_search2") 321 qs << shared_options.merge(analyzer: "searchkick_search2")
322 end 322 end
323 exclude_analyzer = "searchkick_search2" 323 exclude_analyzer = "searchkick_search2"
test/language_test.rb
@@ -64,6 +64,15 @@ class LanguageTest &lt; Minitest::Test @@ -64,6 +64,15 @@ class LanguageTest &lt; Minitest::Test
64 end 64 end
65 end 65 end
66 66
  67 + def test_vietnamese
  68 + # requires https://github.com/duydo/elasticsearch-analysis-vietnamese
  69 + with_options(Song, language: "vietnamese") do
  70 + store_names ["công nghệ thông tin Việt Nam"], Song
  71 + assert_language_search "công nghệ thông tin", ["công nghệ thông tin Việt Nam"]
  72 + assert_language_search "công", []
  73 + end
  74 + end
  75 +
67 def assert_language_search(term, expected) 76 def assert_language_search(term, expected)
68 assert_search term, expected, {misspellings: false}, Song 77 assert_search term, expected, {misspellings: false}, Song
69 end 78 end