Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14037422
D18547.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
5 KB
Referenced Files
None
Subscribers
None
D18547.diff
View Options
diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -2840,6 +2840,7 @@
'PhabricatorFerretFulltextEngineExtension' => 'applications/search/engineextension/PhabricatorFerretFulltextEngineExtension.php',
'PhabricatorFerretInterface' => 'applications/search/ferret/PhabricatorFerretInterface.php',
'PhabricatorFerretNgrams' => 'applications/search/ferret/PhabricatorFerretNgrams.php',
+ 'PhabricatorFerretSearchEngineExtension' => 'applications/search/engineextension/PhabricatorFerretSearchEngineExtension.php',
'PhabricatorFile' => 'applications/files/storage/PhabricatorFile.php',
'PhabricatorFileAES256StorageFormat' => 'applications/files/format/PhabricatorFileAES256StorageFormat.php',
'PhabricatorFileBundleLoader' => 'applications/files/query/PhabricatorFileBundleLoader.php',
@@ -8173,6 +8174,7 @@
'PhabricatorFerretField' => 'PhabricatorSearchDAO',
'PhabricatorFerretFulltextEngineExtension' => 'PhabricatorFulltextEngineExtension',
'PhabricatorFerretNgrams' => 'PhabricatorSearchDAO',
+ 'PhabricatorFerretSearchEngineExtension' => 'PhabricatorSearchEngineExtension',
'PhabricatorFile' => array(
'PhabricatorFileDAO',
'PhabricatorApplicationTransactionInterface',
diff --git a/src/applications/maniphest/query/ManiphestTaskSearchEngine.php b/src/applications/maniphest/query/ManiphestTaskSearchEngine.php
--- a/src/applications/maniphest/query/ManiphestTaskSearchEngine.php
+++ b/src/applications/maniphest/query/ManiphestTaskSearchEngine.php
@@ -49,8 +49,6 @@
$subtype_map = id(new ManiphestTask())->newEditEngineSubtypeMap();
$hide_subtypes = (count($subtype_map) == 1);
- $hide_ferret = !PhabricatorEnv::getEnvConfig('phabricator.show-prototypes');
-
return array(
id(new PhabricatorOwnersSearchField())
->setLabel(pht('Assigned To'))
@@ -91,10 +89,6 @@
id(new PhabricatorSearchTextField())
->setLabel(pht('Contains Words'))
->setKey('fulltext'),
- id(new PhabricatorSearchTextField())
- ->setLabel(pht('Query (Prototype)'))
- ->setKey('query')
- ->setIsHidden($hide_ferret),
id(new PhabricatorSearchThreeStateField())
->setLabel(pht('Open Parents'))
->setKey('hasParents')
@@ -150,7 +144,6 @@
'statuses',
'priorities',
'subtypes',
- 'query',
'fulltext',
'hasParents',
'hasSubtasks',
@@ -231,27 +224,6 @@
$query->withFullTextSearch($map['fulltext']);
}
- if (strlen($map['query'])) {
- $raw_query = $map['query'];
-
- $compiler = id(new PhutilSearchQueryCompiler())
- ->setEnableFunctions(true);
-
- $raw_tokens = $compiler->newTokens($raw_query);
-
- $fulltext_tokens = array();
- foreach ($raw_tokens as $raw_token) {
- $fulltext_token = id(new PhabricatorFulltextToken())
- ->setToken($raw_token);
-
- $fulltext_tokens[] = $fulltext_token;
- }
-
- $query->withFerretConstraint(
- id(new ManiphestTask())->newFerretEngine(),
- $fulltext_tokens);
- }
-
if ($map['parentIDs']) {
$query->withParentTaskIDs($map['parentIDs']);
}
diff --git a/src/applications/search/engineextension/PhabricatorFerretSearchEngineExtension.php b/src/applications/search/engineextension/PhabricatorFerretSearchEngineExtension.php
new file mode 100644
--- /dev/null
+++ b/src/applications/search/engineextension/PhabricatorFerretSearchEngineExtension.php
@@ -0,0 +1,70 @@
+<?php
+
+final class PhabricatorFerretSearchEngineExtension
+ extends PhabricatorSearchEngineExtension {
+
+ const EXTENSIONKEY = 'ferret';
+
+ public function isExtensionEnabled() {
+ return PhabricatorEnv::getEnvConfig('phabricator.show-prototypes');
+ }
+
+ public function getExtensionName() {
+ return pht('Fulltext Search');
+ }
+
+ public function getExtensionOrder() {
+ return 1000;
+ }
+
+ public function supportsObject($object) {
+ return ($object instanceof PhabricatorFerretInterface);
+ }
+
+ public function applyConstraintsToQuery(
+ $object,
+ $query,
+ PhabricatorSavedQuery $saved,
+ array $map) {
+
+ if (!strlen($map['query'])) {
+ return;
+ }
+
+ $engine = $object->newFerretEngine();
+
+ $raw_query = $map['query'];
+
+ $compiler = id(new PhutilSearchQueryCompiler())
+ ->setEnableFunctions(true);
+
+ $raw_tokens = $compiler->newTokens($raw_query);
+
+ $fulltext_tokens = array();
+ foreach ($raw_tokens as $raw_token) {
+ $fulltext_token = id(new PhabricatorFulltextToken())
+ ->setToken($raw_token);
+
+ $fulltext_tokens[] = $fulltext_token;
+ }
+
+ $query->withFerretConstraint($engine, $fulltext_tokens);
+ }
+
+ public function getSearchFields($object) {
+ $fields = array();
+
+ $fields[] = id(new PhabricatorSearchTextField())
+ ->setKey('query')
+ ->setLabel(pht('Query (Prototype)'))
+ ->setDescription(pht('Fulltext search.'));
+
+ return $fields;
+ }
+
+ public function getSearchAttachments($object) {
+ return array();
+ }
+
+
+}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Nov 11, 3:46 PM (2 d, 18 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6734851
Default Alt Text
D18547.diff (5 KB)
Attached To
Mode
D18547: Support Ferret engine queries in ApplicationSearch via extension instead of hard-code
Attached
Detach File
Event Timeline
Log In to Comment