diff options
author | Ivan Tashkinov <ivantashkinov@gmail.com> | 2020-07-08 22:50:15 +0300 |
---|---|---|
committer | Ivan Tashkinov <ivantashkinov@gmail.com> | 2020-07-08 22:50:15 +0300 |
commit | 123352ffa1c80aab658fca0c2276d1c06de43a02 (patch) | |
tree | 9964dd902cf615aa50d743650158cc24f1b6cc4e /lib | |
parent | 704a3830556d94e0dbc39873480e9ba95a143be9 (diff) | |
download | pleroma-123352ffa1c80aab658fca0c2276d1c06de43a02.tar.gz pleroma-123352ffa1c80aab658fca0c2276d1c06de43a02.zip |
Removed unused trigram index on `users`. Fixed `users_fts_index` usage.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/pleroma/user/search.ex | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/lib/pleroma/user/search.ex b/lib/pleroma/user/search.ex index 7ff1c7e24..d4fd31069 100644 --- a/lib/pleroma/user/search.ex +++ b/lib/pleroma/user/search.ex @@ -69,11 +69,15 @@ defmodule Pleroma.User.Search do u in query, where: fragment( + # The fragment must _exactly_ match `users_fts_index`, otherwise the index won't work """ - (to_tsvector('simple', ?) || to_tsvector('simple', ?)) @@ to_tsquery('simple', ?) + ( + setweight(to_tsvector('simple', regexp_replace(?, '\\W', ' ', 'g')), 'A') || + setweight(to_tsvector('simple', regexp_replace(coalesce(?, ''), '\\W', ' ', 'g')), 'B') + ) @@ to_tsquery('simple', ?) """, - u.name, u.nickname, + u.name, ^query_string ) ) @@ -95,9 +99,11 @@ defmodule Pleroma.User.Search do select_merge: %{ search_rank: fragment( - "similarity(?, ?) + \ - similarity(?, regexp_replace(?, '@.+', '')) + \ - similarity(?, trim(coalesce(?, '')))", + """ + similarity(?, ?) + + similarity(?, regexp_replace(?, '@.+', '')) + + similarity(?, trim(coalesce(?, ''))) + """, ^query_string, u.nickname, ^query_string, |