FTS prefix search - put full hits first

From: cen <imbacen(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: FTS prefix search - put full hits first
Date: 2017-01-23 15:58:06
Message-ID: d3d4730b-2fa4-5310-6c49-d16e2cf553fa@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi

I have this FTS query:

SELECT * FROM receivers r WHERE r.tsv @@ unaccent('john:*')::tsquery
ORDER BY ts_rank(r.tsv, unaccent('john:*')::tsquery) DESC;

Is there any way to tell FTS to put records with "John" first and others
after that (Johhny, Johnson etc)?

Basically, I want to have full word hits on top.

Best regards, Klemen

Browse pgsql-general by date

  From Date Subject
Next Message Kased, Razy (Chemistry and Geosciences) 2017-01-23 17:08:47 What is the purpose of PostGIS on PostgreSQL?
Previous Message Alexander Shchapov 2017-01-23 11:32:31 Detailed progress reporting for "vacuuming indexes" stage