[GENERAL] Use full text to rank results higher if they are "closer hit" - Mailing list pgsql-general

From Thomas Nyberg
Subject [GENERAL] Use full text to rank results higher if they are "closer hit"
Date
Msg-id 7104da68-158b-de80-b1ba-47c934e1c87f@gmx.com
Whole thread Raw
Responses Re: [GENERAL] Use full text to rank results higher if they are"closer hit"  (Artur Zakirov <a.zakirov@postgrespro.ru>)
Re: [GENERAL] Use full text to rank results higher if they are"closer hit"  (Adrian Klaver <adrian.klaver@aklaver.com>)
Re: [GENERAL] Use full text to rank results higher if they are "closer hit"  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
Hello,

I think it's easier to explain my question with example code:

------------------------
CREATE TABLE t ( s VARCHAR );
CREATE TABLE

INSERT INTO t VALUES ('hello'), ('hello world');
INSERT 0 2

SELECT * FROM t;
       s
-------------
  hello
  hello world
(2 rows)

SELECT s, ts_rank(vector, query) AS rank
FROM t, to_tsvector(s) vector, to_tsquery('hello') query
WHERE query @@ vector;
       s      |   rank
-------------+-----------
  hello       | 0.0607927
  hello world | 0.0607927
(2 rows)
------------------------

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.

Thanks for any help!

Cheers,
Thomas


pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: [GENERAL] database folder name and tables filenames
Next
From: Adrian Klaver
Date:
Subject: Re: [GENERAL] database folder name and tables filenames