diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index b413985624..b9c2dedf1d 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -2840,6 +2840,7 @@ phutil_register_library_map(array( '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 @@ phutil_register_library_map(array( '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 index 0e3e0db69f..150ec81def 100644 --- a/src/applications/maniphest/query/ManiphestTaskSearchEngine.php +++ b/src/applications/maniphest/query/ManiphestTaskSearchEngine.php @@ -49,8 +49,6 @@ final class ManiphestTaskSearchEngine $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 @@ final class ManiphestTaskSearchEngine 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 @@ final class ManiphestTaskSearchEngine 'statuses', 'priorities', 'subtypes', - 'query', 'fulltext', 'hasParents', 'hasSubtasks', @@ -231,27 +224,6 @@ final class ManiphestTaskSearchEngine $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 index 0000000000..02aadf7336 --- /dev/null +++ b/src/applications/search/engineextension/PhabricatorFerretSearchEngineExtension.php @@ -0,0 +1,70 @@ +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(); + } + + +}