Prioritizing exact "starts with" matches, then tsearch results

24 views
Skip to first unread message

Pascal Laliberte

unread,
Sep 16, 2020, 3:35:16 PM9/16/20
to Case Commons Development
I'd like certain matches to rank higher than the rest of the tsearch queries when the search phrase is exactly matching the beginning of a particular field...

I'm thinking something like adding an extra SELECT item called something like :rank_matches_title that returns a higher number if the search phrase matches exactly the :title field, or a little lower-but-still-high is the search phrase matches the start of the :title field. And then, ordering the overall results first by :rank_matches_title and then by whatever ranking the pg_search uses to order the results.

Am I on the right track?
Reply all
Reply to author
Forward
0 new messages