Skip to content

Commit 8524bf0

Browse files
committed
[PGPRO-5136] Fix bug with losing results in phrase search in index without
positional information (e.g. addon_ops). Per report: #93 tags: rum
1 parent 9e1b441 commit 8524bf0

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

src/rum_ts_utils.c

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -600,6 +600,14 @@ rum_phrase_execute(QueryItem *curitem, void *arg, uint32 flags,
600600

601601
if (curitem->qoperator.oper == OP_PHRASE)
602602
{
603+
/* In case of index where position is not available
604+
* (e.g. addon_ops) output TS_MAYBE even in case both
605+
* lmatch and rmatch are TS_YES. Otherwise we can lose
606+
* results of phrase queries.
607+
*/
608+
if (flags & TS_EXEC_PHRASE_NO_POS)
609+
return TS_MAYBE;
610+
603611
/*
604612
* Compute Loffset and Roffset suitable for phrase match, and
605613
* compute overall width of whole phrase match.
@@ -829,13 +837,10 @@ rum_TS_execute(QueryItem *curitem, void *arg, uint32 flags,
829837
case OP_PHRASE:
830838

831839
/*
832-
* If we get a MAYBE result, and the caller doesn't want that,
833-
* convert it to NO. It would be more consistent, perhaps, to
834-
* return the result of TS_phrase_execute() verbatim and then
835-
* convert MAYBE results at the top of the recursion. But
836-
* converting at the topmost phrase operator gives results that
837-
* are bug-compatible with the old implementation, so do it like
838-
* this for now.
840+
* Checking for TS_EXEC_PHRASE_NO_POS has been moved inside
841+
* rum_phrase_execute, otherwise we can lose results of phrase
842+
* operator when position information is not available in index
843+
* (e.g. index built with addon_ops)
839844
*/
840845
switch (rum_phrase_execute(curitem, arg, flags, chkcond, NULL))
841846
{
@@ -844,7 +849,7 @@ rum_TS_execute(QueryItem *curitem, void *arg, uint32 flags,
844849
case TS_YES:
845850
return TS_YES;
846851
case TS_MAYBE:
847-
return (flags & TS_EXEC_PHRASE_NO_POS) ? TS_MAYBE : TS_NO;
852+
return TS_MAYBE;
848853
}
849854
break;
850855

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy