From 5cfa43953f69f7c6471568425b5ae53411e1d2c8 Mon Sep 17 00:00:00 2001 From: Tyketc <127599209+Tyketc@users.noreply.github.com> Date: Sat, 23 Sep 2023 09:01:53 +0000 Subject: [PATCH] Update Chinese search optimization for 4.2.0 See mastodon/mastodon#27024 --- content/en/admin/elasticsearch.md | 37 +++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/content/en/admin/elasticsearch.md b/content/en/admin/elasticsearch.md index 234097b7..32f77c49 100644 --- a/content/en/admin/elasticsearch.md +++ b/content/en/admin/elasticsearch.md @@ -170,6 +170,43 @@ diff --git a/app/chewy/accounts_index.rb b/app/chewy/accounts_index.rb filter: %w(lowercase asciifolding cjk_width), }, +diff --git a/app/chewy/public_statuses_index.rb b/app/chewy/public_statuses_index.rb +--- a/app/chewy/public_statuses_index.rb ++++ b/app/chewy/public_statuses_index.rb +@@ -19,6 +19,15 @@ class PublicStatusesIndex < Chewy::Index + }, + }, + ++ char_filter: { ++ tsconvert: { ++ type: 'stconvert', ++ keep_both: false, ++ delimiter: '#', ++ convert_type: 't2s', ++ }, ++ }, ++ + analyzer: { + verbatim: { + tokenizer: 'uax_url_email', +@@ -26,7 +35,7 @@ class PublicStatusesIndex < Chewy::Index + }, + + content: { +- tokenizer: 'standard', ++ tokenizer: 'ik_max_word', + filter: %w( + lowercase + asciifolding +@@ -36,6 +45,7 @@ class PublicStatusesIndex < Chewy::Index + english_stop + english_stemmer + ), ++ char_filter: %w(tsconvert), + }, + + hashtag: { + diff --git a/app/chewy/statuses_index.rb b/app/chewy/statuses_index.rb --- a/app/chewy/statuses_index.rb +++ b/app/chewy/statuses_index.rb