3 final class PhabricatorFerretSearchEngineExtension
4 extends PhabricatorSearchEngineExtension
{
6 const EXTENSIONKEY
= 'ferret';
8 public function isExtensionEnabled() {
12 public function getExtensionName() {
13 return pht('Fulltext Search');
16 public function getExtensionOrder() {
20 public function supportsObject($object) {
21 return ($object instanceof PhabricatorFerretInterface
);
24 public function applyConstraintsToQuery(
27 PhabricatorSavedQuery
$saved,
30 if (!strlen($map['query'])) {
34 $engine = $object->newFerretEngine();
36 $raw_query = $map['query'];
38 $compiler = id(new PhutilSearchQueryCompiler())
39 ->setEnableFunctions(true);
41 $raw_tokens = $compiler->newTokens($raw_query);
43 $fulltext_tokens = array();
44 foreach ($raw_tokens as $raw_token) {
45 $fulltext_token = id(new PhabricatorFulltextToken())
46 ->setToken($raw_token);
48 $fulltext_tokens[] = $fulltext_token;
51 $query->withFerretConstraint($engine, $fulltext_tokens);
54 public function getSearchFields($object) {
57 $fields[] = id(new PhabricatorSearchTextField())
59 ->setLabel(pht('Query'))
62 'Find objects matching a fulltext search query. See '.
63 '"Search User Guide" in the documentation for details.'));
68 public function getSearchAttachments($object) {