Re: Use full text to rank results higher if they are "closer hit"

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Thomas Nyberg <tomuxiong(at)gmx(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Use full text to rank results higher if they are "closer hit"
Date: 2017-02-14 16:04:06
Message-ID: 11992.1487088246@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Thomas Nyberg <tomuxiong(at)gmx(dot)com> writes:
> Here both 'hello' and 'hello world' are ranked equally highly when
> searching with 'hello'. What I'm wondering is, is there a way within
> postgres to have it match higher to just 'hello' than 'hello world'?
> I.e. something like it slightly down-weights extraneous terms? Of course
> in general I don't know the query or the field strings ahead of time.

Read the documentation for ts_rank --- there's a normalization option
for that.

I'd also suggest you might prefer using ts_rank_cd, which is supposed to
penalize cases where the matching words aren't close together.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Thomas Nyberg 2017-02-14 16:07:28 Re: Use full text to rank results higher if they are "closer hit"
Previous Message Adrian Klaver 2017-02-14 16:00:13 Re: Use full text to rank results higher if they are "closer hit"