diff --git a/app/chewy/statuses_index.rb b/app/chewy/statuses_index.rb index 47cb856ea9..f364eb10f1 100644 --- a/app/chewy/statuses_index.rb +++ b/app/chewy/statuses_index.rb @@ -58,6 +58,7 @@ class StatusesIndex < Chewy::Index field :text, type: 'text', value: ->(status) { [status.spoiler_text, Formatter.instance.plaintext(status)].concat(status.media_attachments.map(&:description)).concat(status.preloadable_poll ? status.preloadable_poll.options : []).join("\n\n") } do field :stemmed, type: 'text', analyzer: 'content' + field :chn , type: 'text', analyzer: 'ik_max_word', search_analyzer: 'ik_smart' end field :searchable_by, type: 'long', value: ->(status, crutches) { status.searchable_by(crutches) } diff --git a/app/lib/search_query_transformer.rb b/app/lib/search_query_transformer.rb index e07ebfffed..42a8a02841 100644 --- a/app/lib/search_query_transformer.rb +++ b/app/lib/search_query_transformer.rb @@ -23,7 +23,7 @@ class SearchQueryTransformer < Parslet::Transform def clause_to_query(clause) case clause when TermClause - { multi_match: { type: 'most_fields', query: clause.term, fields: ['text', 'text.stemmed'] } } + { multi_match: { type: 'most_fields', query: clause.term, fields: clause.term.match?('^[a-zA-Z]*$') ? ['text', 'text.stemmed'] : ['text.chn']} } when PhraseClause { match_phrase: { text: { query: clause.phrase } } } else