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:
@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user