Commit 5667c9544a8f1c294cf1cdf4f22e2bb0d613737f
1 parent
67f40267
Exists in
master
and in
18 other branches
Added support for Vietnamese [skip ci]
Showing
5 changed files
with
25 additions
and
3 deletions
Show diff stats
CHANGELOG.md
1 | 1 | ## 3.0.2 [unreleased] |
2 | 2 | |
3 | -- Added support for Korean | |
3 | +- Added support for Korean and Vietnamese | |
4 | 4 | - Fixed `Unsupported argument type: Symbol` for async partial reindex |
5 | 5 | - Fixed infinite recursion with multi search and misspellings below |
6 | 6 | - Do not raise an error when `id` is indexed | ... | ... |
README.md
... | ... | @@ -304,9 +304,10 @@ A few languages require plugins: |
304 | 304 | |
305 | 305 | - `chinese` - [elasticsearch-analysis-ik plugin](https://github.com/medcl/elasticsearch-analysis-ik) |
306 | 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 | 308 | - `polish` - [analysis-stempel plugin](https://www.elastic.co/guide/en/elasticsearch/plugins/6.2/analysis-stempel.html) |
309 | 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 | 312 | ### Synonyms |
312 | 313 | ... | ... |
lib/searchkick/index_options.rb
... | ... | @@ -181,6 +181,18 @@ module Searchkick |
181 | 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 | 196 | when "polish", "ukrainian", "smartcn" |
185 | 197 | settings[:analysis][:analyzer].merge!( |
186 | 198 | default_analyzer => { | ... | ... |
lib/searchkick/query.rb
... | ... | @@ -317,7 +317,7 @@ module Searchkick |
317 | 317 | qs << shared_options.merge(analyzer: "searchkick_search") |
318 | 318 | |
319 | 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 | 321 | qs << shared_options.merge(analyzer: "searchkick_search2") |
322 | 322 | end |
323 | 323 | exclude_analyzer = "searchkick_search2" | ... | ... |
test/language_test.rb
... | ... | @@ -64,6 +64,15 @@ class LanguageTest < Minitest::Test |
64 | 64 | end |
65 | 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 | 76 | def assert_language_search(term, expected) |
68 | 77 | assert_search term, expected, {misspellings: false}, Song |
69 | 78 | end | ... | ... |