Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15190212
D18536.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D18536.diff
View Options
diff --git a/src/applications/maniphest/search/ManiphestTaskFerretEngine.php b/src/applications/maniphest/search/ManiphestTaskFerretEngine.php
--- a/src/applications/maniphest/search/ManiphestTaskFerretEngine.php
+++ b/src/applications/maniphest/search/ManiphestTaskFerretEngine.php
@@ -15,4 +15,13 @@
return new ManiphestTaskFerretField();
}
+ protected function getFunctionMap() {
+ $map = parent::getFunctionMap();
+
+ $map['body']['aliases'][] = 'desc';
+ $map['body']['aliases'][] = 'description';
+
+ return $map;
+ }
+
}
diff --git a/src/applications/search/ferret/PhabricatorFerretEngine.php b/src/applications/search/ferret/PhabricatorFerretEngine.php
--- a/src/applications/search/ferret/PhabricatorFerretEngine.php
+++ b/src/applications/search/ferret/PhabricatorFerretEngine.php
@@ -6,6 +6,65 @@
abstract public function newDocumentObject();
abstract public function newFieldObject();
+ public function getDefaultFunctionKey() {
+ return 'all';
+ }
+
+ public function getFieldForFunction($function) {
+ $function = phutil_utf8_strtolower($function);
+
+ $map = $this->getFunctionMap();
+ if (!isset($map[$function])) {
+ throw new PhutilSearchQueryCompilerSyntaxException(
+ pht(
+ 'Unknown search function "%s". Supported functions are: %s.',
+ $function,
+ implode(', ', array_keys($map))));
+ }
+
+ return $map[$function]['field'];
+ }
+
+ public function getAllFunctionFields() {
+ $map = $this->getFunctionMap();
+
+ $fields = array();
+ foreach ($map as $key => $spec) {
+ $fields[] = $spec['field'];
+ }
+
+ return $fields;
+ }
+
+ protected function getFunctionMap() {
+ return array(
+ 'all' => array(
+ 'field' => PhabricatorSearchDocumentFieldType::FIELD_ALL,
+ 'aliases' => array(
+ 'any',
+ ),
+ ),
+ 'title' => array(
+ 'field' => PhabricatorSearchDocumentFieldType::FIELD_TITLE,
+ 'aliases' => array(),
+ ),
+ 'body' => array(
+ 'field' => PhabricatorSearchDocumentFieldType::FIELD_BODY,
+ 'aliases' => array(),
+ ),
+ 'core' => array(
+ 'field' => PhabricatorSearchDocumentFieldType::FIELD_CORE,
+ 'aliases' => array(),
+ ),
+ 'comment' => array(
+ 'field' => PhabricatorSearchDocumentFieldType::FIELD_COMMENT,
+ 'aliases' => array(
+ 'comments',
+ ),
+ ),
+ );
+ }
+
public function newStemmer() {
return new PhutilSearchStemmer();
}
diff --git a/src/infrastructure/query/policy/PhabricatorCursorPagedPolicyAwareQuery.php b/src/infrastructure/query/policy/PhabricatorCursorPagedPolicyAwareQuery.php
--- a/src/infrastructure/query/policy/PhabricatorCursorPagedPolicyAwareQuery.php
+++ b/src/infrastructure/query/policy/PhabricatorCursorPagedPolicyAwareQuery.php
@@ -1402,15 +1402,7 @@
$this->ferretEngine = $engine;
$this->ferretTokens = $fulltext_tokens;
-
- $function_map = array(
- 'all' => PhabricatorSearchDocumentFieldType::FIELD_ALL,
- 'title' => PhabricatorSearchDocumentFieldType::FIELD_TITLE,
- 'body' => PhabricatorSearchDocumentFieldType::FIELD_BODY,
- 'core' => PhabricatorSearchDocumentFieldType::FIELD_CORE,
- );
-
- $current_function = 'all';
+ $current_function = $engine->getDefaultFunctionKey();
$table_map = array();
$idx = 1;
foreach ($this->ferretTokens as $fulltext_token) {
@@ -1421,18 +1413,13 @@
$function = $current_function;
}
- if (!isset($function_map[$function])) {
- throw new PhutilSearchQueryCompilerSyntaxException(
- pht(
- 'Unknown search function "%s".',
- $function));
- }
+ $raw_field = $engine->getFieldForFunction($function);
if (!isset($table_map[$function])) {
$alias = 'ftfield'.$idx++;
$table_map[$function] = array(
'alias' => $alias,
- 'key' => $function_map[$function],
+ 'key' => $raw_field,
);
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Feb 22, 7:49 PM (9 h, 47 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7182444
Default Alt Text
D18536.diff (3 KB)
Attached To
Mode
D18536: Move Ferret engine "title:..." field definitions to the engine itself
Attached
Detach File
Event Timeline
Log In to Comment