Skip to content

Instantly share code, notes, and snippets.

@boserup
Created Dec 4, 2017
Embed
What would you like to do?
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