From: | Javier Ayres <jayres(at)sophilabs(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Weird ranking results with ts_rank |
Date: | 2019-11-14 19:38:39 |
Message-ID: | CAC1P-g1YPwVK9ggiRLq=MvGeMp=ciSCsGTnM3L__rWExWTLUdQ@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hi everybody.
I'm implementing a solution that uses PostgreSQL's full text search
capabilities and I have come across a particular set of results for ts_rank
that don't seem to make sense according to the documentation. I have tried
the following queries in PostgreSQL 10, 11 and 12.
In both cases only the word "box" is matching, but adding a non-matching
word with OR to the query increases the ranking. If I keep adding more
non-matching words with OR the ranking starts to decrease again, but I
would imagine that the second option should have the highest score and it
would start decreasing from there the more non-matching words I add.
Is there something I'm not understanding?
Thanks.
postgres=# select ts_rank(to_tsvector('search for a text box'),
to_tsquery('circle | lot <-> box'));
ts_rank
-------------
0.020264236
(1 row)
postgres=# select ts_rank(to_tsvector('search for a text box'),
to_tsquery('lot <-> box'));
ts_rank
---------
1e-20
(1 row)
--
Javier Ayres
Data Engineer
+1 855 636 5811 <+18556365811> - sophilabs.co
From | Date | Subject | |
---|---|---|---|
Next Message | Jeff Ross | 2019-11-14 23:43:01 | Re: Query which shows FK child columns? |
Previous Message | Ron | 2019-11-14 18:49:03 | Query which shows FK child columns? |