1
0
mirror of https://github.com/postgres/postgres.git synced 2025-09-02 04:21:28 +03:00

Fix ts_rank_cd() to ignore stripped lexemes

Previously, stripped lexemes got a default location and could be
considered if mixed with non-stripped lexemes.

BACKWARD INCOMPATIBILITY CHANGE
This commit is contained in:
Bruce Momjian
2014-03-24 14:36:36 -04:00
parent bb42e21be2
commit 1420f3a982
4 changed files with 30 additions and 5 deletions

View File

@@ -658,8 +658,9 @@ get_docrep(TSVector txt, QueryRepresentation *qr, int *doclen)
}
else
{
dimt = POSNULL.npos;
post = POSNULL.pos;
/* ignore words without positions */
entry++;
continue;
}
while (cur + dimt >= len)

View File

@@ -596,6 +596,20 @@ S. T. Coleridge (1772-1834)
0.1
(1 row)
SELECT ts_rank_cd(strip(to_tsvector('both stripped')),
to_tsquery('both & stripped'));
ts_rank_cd
------------
0
(1 row)
SELECT ts_rank_cd(to_tsvector('unstripped') || strip(to_tsvector('stripped')),
to_tsquery('unstripped & stripped'));
ts_rank_cd
------------
0
(1 row)
--headline tests
SELECT ts_headline('english', '
Day after day, day after day,

View File

@@ -165,6 +165,12 @@ Water, water, every where,
S. T. Coleridge (1772-1834)
'), to_tsquery('english', 'ocean'));
SELECT ts_rank_cd(strip(to_tsvector('both stripped')),
to_tsquery('both & stripped'));
SELECT ts_rank_cd(to_tsvector('unstripped') || strip(to_tsvector('stripped')),
to_tsquery('unstripped & stripped'));
--headline tests
SELECT ts_headline('english', '
Day after day, day after day,