From eba4feddf8a15f2bc702fc38d03355b2d1575e59 Mon Sep 17 00:00:00 2001 From: KMY Date: Mon, 28 Aug 2023 09:37:24 +0900 Subject: [PATCH] Improve elasticsearch sudachi setting --- app/chewy/public_statuses_index.rb | 6 +++--- app/chewy/statuses_index.rb | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/chewy/public_statuses_index.rb b/app/chewy/public_statuses_index.rb index 73482ede1c..796e83249f 100644 --- a/app/chewy/public_statuses_index.rb +++ b/app/chewy/public_statuses_index.rb @@ -73,14 +73,14 @@ class PublicStatusesIndex < Chewy::Index tokenizer: { sudachi_tokenizer: { resources_path: '/etc/elasticsearch/sudachi', - split_mode: 'C', + split_mode: 'A', type: 'sudachi_tokenizer', discard_punctuation: 'true', }, }, }.freeze - settings index: index_preset(refresh_interval: '30s', number_of_shards: 5), analysis: Rails.env.development? ? DEVELOPMENT_SETTINGS : PRODUCTION_SETTINGS + settings index: index_preset(refresh_interval: '30s', number_of_shards: 5), analysis: PRODUCTION_SETTINGS index_scope ::Status.unscoped .kept @@ -90,7 +90,7 @@ class PublicStatusesIndex < Chewy::Index root date_detection: false do field(:id, type: 'keyword') field(:account_id, type: 'long') - field(:text, type: 'text', analyzer: 'whitespace', value: ->(status) { status.searchable_text }) { field(:stemmed, type: 'text', analyzer: 'content') } + field(:text, type: 'text', analyzer: 'sudachi_analyzer', value: ->(status) { status.searchable_text }) { field(:stemmed, type: 'text', analyzer: 'content') } field(:language, type: 'keyword') field(:domain, type: 'keyword', value: ->(status) { status.account.domain || '' }) field(:properties, type: 'keyword', value: ->(status) { status.searchable_properties }) diff --git a/app/chewy/statuses_index.rb b/app/chewy/statuses_index.rb index 654aa3b401..107efe8f77 100644 --- a/app/chewy/statuses_index.rb +++ b/app/chewy/statuses_index.rb @@ -71,14 +71,14 @@ class StatusesIndex < Chewy::Index tokenizer: { sudachi_tokenizer: { resources_path: '/etc/elasticsearch/sudachi', - split_mode: 'C', + split_mode: 'A', type: 'sudachi_tokenizer', discard_punctuation: 'true', }, }, }.freeze - settings index: index_preset(refresh_interval: '30s', number_of_shards: 5), analysis: Rails.env.development? ? DEVELOPMENT_SETTINGS : PRODUCTION_SETTINGS + settings index: index_preset(refresh_interval: '30s', number_of_shards: 5), analysis: PRODUCTION_SETTINGS # We do not use delete_if option here because it would call a method that we # expect to be called with crutches without crutches, causing n+1 queries @@ -122,7 +122,7 @@ class StatusesIndex < Chewy::Index root date_detection: false do field(:id, type: 'keyword') field(:account_id, type: 'long') - field(:text, type: 'text', analyzer: 'whitespace', value: ->(status) { status.searchable_text }) { field(:stemmed, type: 'text', analyzer: 'content') } + field(:text, type: 'text', analyzer: 'sudachi_analyzer', value: ->(status) { status.searchable_text }) { field(:stemmed, type: 'text', analyzer: 'content') } field(:searchable_by, type: 'long', value: ->(status, crutches) { status.searchable_by(crutches) }) field(:searchability, type: 'keyword', value: ->(status) { status.compute_searchability }) field(:language, type: 'keyword')