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

2017-02-14 Thread Thomas Nyberg
Excellent great info! To save the extra mailing list pings, thanks to _everyone_ this is exactly what I was looking for. Cheers, Thomas -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general

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

2017-02-14 Thread Artur Zakirov
On 14.02.2017 18:35, Thomas Nyberg wrote: 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

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

2017-02-14 Thread Adrian Klaver
On 02/14/2017 07:35 AM, Thomas Nyberg wrote: > 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 >

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

2017-02-14 Thread Tom Lane
Thomas Nyberg 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

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

2017-02-14 Thread Artur Zakirov
On 14.02.2017 18:57, Artur Zakirov wrote: Hello, try the query: 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.0303964 (2 rows)

[GENERAL] Use full text to rank results higher if they are "closer hit"

2017-02-14 Thread Thomas Nyberg
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,