Re: Question about ranking & full text

From: Artur Zakirov <a(dot)zakirov(at)postgrespro(dot)ru>
To: Nicolas Paris <niparisco(at)gmail(dot)com>, Forums postgresql <pgsql-general(at)postgresql(dot)org>
Subject: Re: Question about ranking & full text
Date: 2016-04-15 13:44:03
Message-ID: 5710F023.8000501@postgrespro.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 15.04.2016 15:47, Nicolas Paris wrote:
> Hi,
> I wonder why the third query returns 0.
> To me, it would return 0.1, because there is not baz in the text
>
> Thanks !
> (pg 9.4)
>
> SELECT ts_rank_cd(apod.t, query,4) AS rank
> FROM (SELECT to_tsvector('foo baz') as t) as apod, to_tsquery('foo &
> baz') query
> WHERE query @@ apod.t;
> rank |
> ------------|
> 0.100000001 |
>
> SELECT ts_rank_cd(apod.t, query,4) AS rank
> FROM (SELECT to_tsvector('foo ') as t) as apod, to_tsquery('foo & !
> baz') query
> WHERE query @@ apod.t;
>
> rank |
> ------------|
> 0.100000001 |
>
> SELECT ts_rank_cd(apod.t, query,4) AS rank
> FROM (SELECT to_tsvector('foo ') as t) as apod, to_tsquery(' ! baz') query
> WHERE query @@ apod.t;
>
> rank |
> ------------|
> 0.0 |
>
>

Hello,

I think this is a right behaviour of the function. Because it computes
how often the query terms appear in the document, how close together the
terms are in the document, and how important is the part of the document
where they occur.

In the third example found terms are empty. And the function can't do
calculates with empty terms. It sees that the terms are empty and
returns 0.0.

--
Artur Zakirov
Postgres Professional: http://www.postgrespro.com
Russian Postgres Company

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Andrej Vanek 2016-04-15 22:28:07 pg_basebackup: return value 1: reason?
Previous Message Nicolas Paris 2016-04-15 12:47:48 Question about ranking & full text