Fix statuses search Elasticsearch query (#26657)
This commit is contained in:
parent
f2ec2876a4
commit
82ec6f162b
|
@ -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 },
|
||||
|
|
Loading…
Reference in New Issue