diff --git a/app/chewy/accounts_index.rb b/app/chewy/accounts_index.rb index cbfcfa1c3..49dfebb1d 100644 --- a/app/chewy/accounts_index.rb +++ b/app/chewy/accounts_index.rb @@ -12,6 +12,19 @@ class AccountsIndex < Chewy::Index tokenizer: 'edge_ngram', filter: %w(lowercase asciifolding cjk_width), }, + + sudachi_content: { + filter: %w( + lowercase + cjk_width + sudachi_part_of_speech + sudachi_ja_stop + sudachi_baseform + search + ), + tokenizer: 'sudachi_tokenizer', + type: 'custom', + }, }, tokenizer: { @@ -20,6 +33,19 @@ class AccountsIndex < Chewy::Index min_gram: 1, max_gram: 15, }, + sudachi_tokenizer: { + type: 'sudachi_tokenizer', + discard_punctuation: true, + resources_path: '/etc/elasticsearch', + settings_path: '/etc/elasticsearch/sudachi.json', + }, + }, + + filter: { + search: { + type: 'sudachi_split', + mode: 'search', + }, }, } @@ -37,6 +63,10 @@ class AccountsIndex < Chewy::Index field :actor_type, type: 'keyword', analyzer: 'content' + field :text, type: 'text', value: ->(account) { account.index_text } do + field :stemmed, type: 'text', analyzer: 'sudachi_content' + end + field :following_count, type: 'long', value: ->(account) { account.following.local.count } field :followers_count, type: 'long', value: ->(account) { account.followers.local.count } field :subscribing_count, type: 'long', value: ->(account) { account.subscribing.local.count } diff --git a/app/chewy/statuses_index.rb b/app/chewy/statuses_index.rb index 9f746c4ee..8852eab77 100644 --- a/app/chewy/statuses_index.rb +++ b/app/chewy/statuses_index.rb @@ -22,11 +22,18 @@ class StatusesIndex < Chewy::Index sudachi_part_of_speech sudachi_ja_stop sudachi_baseform + search ), tokenizer: 'sudachi_tokenizer', type: 'custom', }, }, + filter: { + search: { + type: 'sudachi_split', + mode: 'search', + }, + }, } define_type ::Status.unscoped.kept.without_reblogs.includes(:media_attachments, :preloadable_poll) do diff --git a/app/models/account.rb b/app/models/account.rb index 3c782ad55..6fca84f13 100644 --- a/app/models/account.rb +++ b/app/models/account.rb @@ -392,6 +392,10 @@ class Account < ApplicationRecord end.permitted_for(self, account) end + def index_text + ActionController::Base.helpers.strip_tags(note) + end + class Field < ActiveModelSerializers::Model attributes :name, :value, :verified_at, :account