Skip to content
Snippets Groups Projects
Verified Commit e7048471 authored by Sergey Suprunenko's avatar Sergey Suprunenko
Browse files

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

parent 6650c69a
Branches bugfix/object-fetching-handle-mrf-reject
No related tags found
No related merge requests found
......@@ -54,33 +54,31 @@ defp query_with(q, :gin, search_query) 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
defp query_with(q, :rum, search_query) do
from([a, o] in q,
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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment