diff options
author | Sergey Suprunenko <suprunenko.s@gmail.com> | 2020-03-31 20:49:54 +0200 |
---|---|---|
committer | Sergey Suprunenko <suprunenko.s@gmail.com> | 2020-03-31 20:49:54 +0200 |
commit | e7048471e067466a31cedee308219ed6fc0bc1cd (patch) | |
tree | 2a62f687c17d3e78c286ffa0c660eb6576c38e34 | |
parent | 6650c69aafd786314204c6617d979393377a7bb7 (diff) | |
download | pleroma-e7048471e067466a31cedee308219ed6fc0bc1cd.tar.gz |
Write both summary and content searches in the same `where` to keep other conditionsfeature/add-subject-to-text-search
-rw-r--r-- | lib/pleroma/activity/search.ex | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/lib/pleroma/activity/search.ex b/lib/pleroma/activity/search.ex index aea371102..fd3b5ee8f 100644 --- a/lib/pleroma/activity/search.ex +++ b/lib/pleroma/activity/search.ex @@ -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 |