Write both summary and content searches in the same where to keep other conditions

This commit is contained in:
Sergey Suprunenko 2020-03-31 20:49:54 +02:00
parent 6650c69aaf
commit e7048471e0
No known key found for this signature in database
GPG Key ID: 5DCA7D1BE3914F9C

View File

@ -54,16 +54,15 @@ defmodule Pleroma.Activity.Search do
from([a, o] in q,
where:
fragment(
"(to_tsvector('english', ?->>'summary') @@ plainto_tsquery('english', ?))",
"to_tsvector('english', ?->>'summary') @@ plainto_tsquery('english', ?)",
o.data,
^search_query
),
or_where:
fragment(
"(to_tsvector('english', ?->>'content') @@ plainto_tsquery('english', ?))",
o.data,
^search_query
)
) or
fragment(
"to_tsvector('english', ?->>'content') @@ plainto_tsquery('english', ?)",
o.data,
^search_query
)
)
end
@ -72,15 +71,14 @@ defmodule Pleroma.Activity.Search do
where:
fragment(
"? @@ plainto_tsquery('english', ?)",
o.fts_content,
^search_query
),
or_where:
fragment(
"? @@ plainto_tsquery('english', ?)",
o.fts_summary,
^search_query
),
) or
fragment(
"? @@ plainto_tsquery('english', ?)",
o.fts_content,
^search_query
),
order_by: [fragment("? <=> now()::date", o.inserted_at)]
)
end