Created
December 4, 2017 09:41
-
-
Save boserup/824e5c7c85c4a71c2522608946bc3ab9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT *, | |
ts_rank( | |
SETWEIGHT( | |
TO_TSVECTOR( | |
'english', | |
COALESCE(search_view.name, '') | |
), | |
'A' | |
) || SETWEIGHT( | |
TO_TSVECTOR( | |
'english', | |
COALESCE(search_view.creator, '') | |
), | |
'B' | |
) || SETWEIGHT( | |
TO_TSVECTOR( | |
'english', | |
COALESCE(search_view.fulldesc, '') | |
), | |
'C' | |
), | |
to_tsquery('english', lower('test|kids|jonas')) | |
) AS rank | |
FROM search_view | |
WHERE | |
( | |
to_tsvector('english', COALESCE(search_view.name, '')) | |
|| to_tsvector('english', COALESCE(search_view.creator, '')) | |
|| to_tsvector('english', COALESCE(search_view.fulldesc, '')) | |
) | |
@@ to_tsquery('english', lower('test|kids|jonas')) | |
ORDER BY rank DESC |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment