From 82ec6f162b617e9c46f23ebea1cf27e1e039121c Mon Sep 17 00:00:00 2001 From: Claire Date: Fri, 25 Aug 2023 17:01:56 +0200 Subject: [PATCH] Fix statuses search Elasticsearch query (#26657) --- app/services/statuses_search_service.rb | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/app/services/statuses_search_service.rb b/app/services/statuses_search_service.rb index 21d6b71b7d..2a4e533cfb 100644 --- a/app/services/statuses_search_service.rb +++ b/app/services/statuses_search_service.rb @@ -15,7 +15,7 @@ class StatusesSearchService < BaseService def status_search_results definition = parsed_query.apply( - StatusesIndex.filter( + Chewy::Search::Request.new(StatusesIndex, PublicStatusesIndex).filter( bool: { should: [ publicly_searchable, @@ -27,9 +27,6 @@ class StatusesSearchService < BaseService ) ) - # This is the best way to submit identical queries to multi-indexes though chewy - definition.instance_variable_get(:@parameters)[:indices].value[:indices] << PublicStatusesIndex - results = definition.collapse(field: :id).order(_id: { order: :desc }).limit(@limit).offset(@offset).objects.compact account_ids = results.map(&:account_id) account_domains = results.map(&:account_domain) @@ -42,13 +39,7 @@ class StatusesSearchService < BaseService def publicly_searchable { - bool: { - must_not: { - exists: { - field: 'searchable_by', - }, - }, - }, + term: { _index: PublicStatusesIndex.index_name }, } end @@ -57,9 +48,7 @@ class StatusesSearchService < BaseService bool: { must: [ { - exists: { - field: 'searchable_by', - }, + term: { _index: StatusesIndex.index_name }, }, { term: { searchable_by: @account.id },