Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15404434
D21107.id50278.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D21107.id50278.diff
View Options
diff --git a/src/applications/search/compiler/PhutilSearchQueryCompiler.php b/src/applications/search/compiler/PhutilSearchQueryCompiler.php
--- a/src/applications/search/compiler/PhutilSearchQueryCompiler.php
+++ b/src/applications/search/compiler/PhutilSearchQueryCompiler.php
@@ -12,6 +12,8 @@
const OPERATOR_AND = 'and';
const OPERATOR_SUBSTRING = 'sub';
const OPERATOR_EXACT = 'exact';
+ const OPERATOR_ABSENT = 'absent';
+ const OPERATOR_PRESENT = 'present';
public function setOperators($operators) {
$this->operators = $operators;
@@ -300,6 +302,22 @@
$require_value = $is_quoted;
switch ($operator) {
+ case self::OPERATOR_NOT:
+ if ($enable_functions && ($token['function'] !== null)) {
+ $operator = self::OPERATOR_ABSENT;
+ $value = null;
+ } else {
+ $require_value = true;
+ }
+ break;
+ case self::OPERATOR_SUBSTRING:
+ if ($enable_functions && ($token['function'] !== null)) {
+ $operator = self::OPERATOR_PRESENT;
+ $value = null;
+ } else {
+ $require_value = true;
+ }
+ break;
default:
$require_value = true;
break;
diff --git a/src/applications/search/compiler/__tests__/PhutilSearchQueryCompilerTestCase.php b/src/applications/search/compiler/__tests__/PhutilSearchQueryCompilerTestCase.php
--- a/src/applications/search/compiler/__tests__/PhutilSearchQueryCompilerTestCase.php
+++ b/src/applications/search/compiler/__tests__/PhutilSearchQueryCompilerTestCase.php
@@ -97,6 +97,8 @@
$op_and = PhutilSearchQueryCompiler::OPERATOR_AND;
$op_sub = PhutilSearchQueryCompiler::OPERATOR_SUBSTRING;
$op_exact = PhutilSearchQueryCompiler::OPERATOR_EXACT;
+ $op_present = PhutilSearchQueryCompiler::OPERATOR_PRESENT;
+ $op_absent = PhutilSearchQueryCompiler::OPERATOR_ABSENT;
$mao = "\xE7\x8C\xAB";
@@ -142,6 +144,18 @@
'title:' => false,
'title:+' => false,
'title:+""' => false,
+ 'title:""' => false,
+
+ 'title:~' => array(
+ array('title', $op_present, null),
+ ),
+
+ 'title:-' => array(
+ array('title', $op_absent, null),
+ ),
+
+ '~' => false,
+ '-' => false,
);
$this->assertCompileFunctionQueries($function_tests);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Mar 19, 7:41 AM (5 d, 15 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7711041
Default Alt Text
D21107.id50278.diff (2 KB)
Attached To
Mode
D21107: Add "absent" and "present" field operators to the Ferret query compiler
Attached
Detach File
Event Timeline
Log In to Comment