1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-26 16:52:41 +01:00

Make the Ferret query compiler keep functions sticky across non-initial quoted tokens

Summary: Ref T13509. In `title:big "red" dog`, keep "title" sticky across all three terms, since this seems like it's probably the best match for intent.

Test Plan: Added unit tests; ran unit tests.

Maniphest Tasks: T13509

Differential Revision: https://secure.phabricator.com/D21111
This commit is contained in:
epriestley 2020-04-14 10:08:45 -07:00
parent 0511b2a012
commit b3a8754013
2 changed files with 16 additions and 1 deletions

View file

@ -358,7 +358,14 @@ final class PhutilSearchQueryCompiler
$result['function'] = $function; $result['function'] = $function;
$is_sticky = !$result['quoted']; // Note that the function remains sticky across quoted terms appearing
// after the function term. For example, all of these terms are title
// terms:
//
// title:a "b c" d
$is_sticky = (!$result['quoted'] || ($token['function'] === null));
switch ($operator) { switch ($operator) {
case self::OPERATOR_ABSENT: case self::OPERATOR_ABSENT:
case self::OPERATOR_PRESENT: case self::OPERATOR_PRESENT:

View file

@ -185,6 +185,14 @@ final class PhutilSearchQueryCompilerTestCase
array(null, $op_and, 'x'), array(null, $op_and, 'x'),
), ),
// Functions like "title:" continue to stick across quotes if the
// quotes aren't the initial argument.
'title:a "b c" d' => array(
array('title', $op_and, 'a'),
array('title', $op_and, 'b c'),
array('title', $op_and, 'd'),
),
// These queries require a field be both present and absent, which is // These queries require a field be both present and absent, which is
// impossible. // impossible.
'title:- title:x' => false, 'title:- title:x' => false,