Fix statuses search Elasticsearch query (#26657)

This commit is contained in:
Claire 2023-08-25 17:01:56 +02:00 committed by GitHub
parent f2ec2876a4
commit 82ec6f162b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 14 deletions

View File

@ -15,7 +15,7 @@ class StatusesSearchService < BaseService
def status_search_results def status_search_results
definition = parsed_query.apply( definition = parsed_query.apply(
StatusesIndex.filter( Chewy::Search::Request.new(StatusesIndex, PublicStatusesIndex).filter(
bool: { bool: {
should: [ should: [
publicly_searchable, 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 results = definition.collapse(field: :id).order(_id: { order: :desc }).limit(@limit).offset(@offset).objects.compact
account_ids = results.map(&:account_id) account_ids = results.map(&:account_id)
account_domains = results.map(&:account_domain) account_domains = results.map(&:account_domain)
@ -42,13 +39,7 @@ class StatusesSearchService < BaseService
def publicly_searchable def publicly_searchable
{ {
bool: { term: { _index: PublicStatusesIndex.index_name },
must_not: {
exists: {
field: 'searchable_by',
},
},
},
} }
end end
@ -57,9 +48,7 @@ class StatusesSearchService < BaseService
bool: { bool: {
must: [ must: [
{ {
exists: { term: { _index: StatusesIndex.index_name },
field: 'searchable_by',
},
}, },
{ {
term: { searchable_by: @account.id }, term: { searchable_by: @account.id },