@@ -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