diff --git a/contrib/tsearch2/query.c b/contrib/tsearch2/query.c index 458c55de27..c812f48b0d 100644 --- a/contrib/tsearch2/query.c +++ b/contrib/tsearch2/query.c @@ -278,7 +278,7 @@ pushval_morph(QPRS_STATE * state, int typeval, char *strval, int lenval, int2 we pushval_asis(state, VAL, prs.words[count].word, prs.words[count].len, weight); pfree(prs.words[count].word); if (count) - pushquery(state, OPR, (int4) '&', 0, 0, 0); + pushquery(state, OPR, (int4) '|', 0, 0, 0); } pfree(prs.words); diff --git a/contrib/tsearch2/tsvector.c b/contrib/tsearch2/tsvector.c index c8002c0ab3..ea50421eb7 100644 --- a/contrib/tsearch2/tsvector.c +++ b/contrib/tsearch2/tsvector.c @@ -635,8 +635,10 @@ uniqueWORD(WORD * a, int4 l) res->alen *= 2; res->pos.apos = (uint16 *) repalloc(res->pos.apos, sizeof(uint16) * res->alen); } - res->pos.apos[res->pos.apos[0] + 1] = LIMITPOS(ptr->pos.pos); - res->pos.apos[0]++; + if ( res->pos.apos[0]==0 || res->pos.apos[res->pos.apos[0]] != LIMITPOS(ptr->pos.pos) ) { + res->pos.apos[res->pos.apos[0] + 1] = LIMITPOS(ptr->pos.pos); + res->pos.apos[0]++; + } } } ptr++;