1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-30 11:03:19 +03:00

1 Fix problem with lost precision in rank with OR-ed lexemes

2 Allow tsquery_in to input void tsquery: resolve dump/restore problem with tsquery
This commit is contained in:
Teodor Sigaev
2005-10-28 13:05:06 +00:00
parent fbff2e9607
commit 21b748e76a
3 changed files with 49 additions and 23 deletions

View File

@ -257,7 +257,7 @@ calc_rank_or(float *w, tsvector * t, QUERYTYPE * q)
int4 dimt,
j,
i;
float res = -1.0;
float res = 0.0;
ITEM **item;
int size = q->size;
@ -266,6 +266,8 @@ calc_rank_or(float *w, tsvector * t, QUERYTYPE * q)
for (i = 0; i < size; i++)
{
float resj,wjm;
int4 jm;
entry = find_wordentry(t, q, item[i]);
if (!entry)
continue;
@ -281,14 +283,27 @@ calc_rank_or(float *w, tsvector * t, QUERYTYPE * q)
post = POSNULL + 1;
}
for (j = 0; j < dimt; j++)
{
if (res < 0)
res = wpos(post[j]);
else
res = 1.0 - (1.0 - res) * (1.0 - wpos(post[j]));
}
resj = 0.0;
wjm = -1.0;
jm = 0;
for (j = 0; j < dimt; j++)
{
resj = resj + wpos(post[j])/((j+1)*(j+1));
if ( wpos(post[j]) > wjm ) {
wjm = wpos(post[j]);
jm = j;
}
}
/*
limit (sum(i/i^2),i->inf) = pi^2/6
resj = sum(wi/i^2),i=1,noccurence,
wi - should be sorted desc,
don't sort for now, just choose maximum weight. This should be corrected
Oleg Bartunov
*/
res = res + ( wjm + resj - wjm/((jm+1)*(jm+1)))/1.64493406685;
}
res = res /size;
pfree(item);
return res;
}