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