Skip to content
Permalink
Browse files

Added official support for smartcn analyzer

  • Loading branch information
ankane committed Nov 13, 2019
1 parent 5472fbd commit 72c3bb853bc2f73abf3710b8bba963f8104abd5c
Showing with 23 additions and 9 deletions.
  1. +1 −1 CHANGELOG.md
  2. +1 −0 README.md
  3. +15 −1 lib/searchkick/index_options.rb
  4. +6 −7 test/language_test.rb
@@ -1,6 +1,6 @@
## 4.1.1 [unreleased]

- Added `korean2` language
- Added `chinese2` and `korean2` languages
- Improved performance of async full reindex

## 4.1.0
@@ -316,6 +316,7 @@ end
A few languages require plugins:

- `chinese` - [analysis-ik plugin](https://github.com/medcl/elasticsearch-analysis-ik)
- `chinese2` - [analysis-smartcn plugin](https://www.elastic.co/guide/en/elasticsearch/plugins/7.4/analysis-smartcn.html)
- `japanese` - [analysis-kuromoji plugin](https://www.elastic.co/guide/en/elasticsearch/plugins/7.4/analysis-kuromoji.html)
- `korean` - [analysis-openkoreantext plugin](https://github.com/open-korean-text/elasticsearch-analysis-openkoreantext)
- `korean2` - [analysis-nori plugin](https://www.elastic.co/guide/en/elasticsearch/plugins/7.4/analysis-nori.html) [master]
@@ -168,6 +168,20 @@ def index_options
}
)

stem = false
when "chinese2", "smartcn"
settings[:analysis][:analyzer].merge!(
default_analyzer => {
type: "smartcn"
},
searchkick_search: {
type: "smartcn"
},
searchkick_search2: {
type: "smartcn"
}
)

stem = false
when "japanese"
settings[:analysis][:analyzer].merge!(
@@ -225,7 +239,7 @@ def index_options
)

stem = false
when "polish", "ukrainian", "smartcn"
when "polish", "ukrainian"
settings[:analysis][:analyzer].merge!(
default_analyzer => {
type: language
@@ -17,10 +17,9 @@ def test_chinese
end
end

# experimental
def test_smartcn
# requires https://www.elastic.co/guide/en/elasticsearch/plugins/6.2/analysis-smartcn.html
with_options(Song, language: "smartcn") do
def test_chinese2
# requires https://www.elastic.co/guide/en/elasticsearch/plugins/7.4/analysis-smartcn.html
with_options(Song, language: "chinese2") do
store_names ["中华人民共和国国歌"], Song
assert_language_search "中华人民共和国", ["中华人民共和国国歌"]
# assert_language_search "国歌", ["中华人民共和国国歌"]
@@ -29,7 +28,7 @@ def test_smartcn
end

def test_japanese
# requires https://www.elastic.co/guide/en/elasticsearch/plugins/6.2/analysis-kuromoji.html
# requires https://www.elastic.co/guide/en/elasticsearch/plugins/7.4/analysis-kuromoji.html
with_options(Song, language: "japanese") do
store_names ["JR新宿駅の近くにビールを飲みに行こうか"], Song
assert_language_search "飲む", ["JR新宿駅の近くにビールを飲みに行こうか"]
@@ -59,15 +58,15 @@ def test_korean2
end

def test_polish
# requires https://www.elastic.co/guide/en/elasticsearch/plugins/6.2/analysis-stempel.html
# requires https://www.elastic.co/guide/en/elasticsearch/plugins/7.4/analysis-stempel.html
with_options(Song, language: "polish") do
store_names ["polski"], Song
assert_language_search "polskimi", ["polski"]
end
end

def test_ukrainian
# requires https://www.elastic.co/guide/en/elasticsearch/plugins/6.2/analysis-ukrainian.html
# requires https://www.elastic.co/guide/en/elasticsearch/plugins/7.4/analysis-ukrainian.html
with_options(Song, language: "ukrainian") do
store_names ["ресторани"], Song
assert_language_search "ресторан", ["ресторани"]

0 comments on commit 72c3bb8

Please sign in to comment.
You can’t perform that action at this time.