@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Support Ferret engine for searching users

Summary:
Ref T12819. Adds support for indexing user accounts so they appear in global fulltext results.

Also, always rank users ahead of other results.

Test Plan: Indexed users. Searched for a user, got that user.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T12819

Differential Revision: https://secure.phabricator.com/D18552

+118
+9
resources/sql/autopatches/20170907.ferret.01.user.doc.sql
··· 1 + CREATE TABLE {$NAMESPACE}_user.user_user_fdocument ( 2 + id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, 3 + objectPHID VARBINARY(64) NOT NULL, 4 + isClosed BOOL NOT NULL, 5 + authorPHID VARBINARY(64), 6 + ownerPHID VARBINARY(64), 7 + epochCreated INT UNSIGNED NOT NULL, 8 + epochModified INT UNSIGNED NOT NULL 9 + ) ENGINE=InnoDB, COLLATE {$COLLATE_TEXT};
+8
resources/sql/autopatches/20170907.ferret.02.user.field.sql
··· 1 + CREATE TABLE {$NAMESPACE}_user.user_user_ffield ( 2 + id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, 3 + documentID INT UNSIGNED NOT NULL, 4 + fieldKey VARCHAR(4) NOT NULL COLLATE {$COLLATE_TEXT}, 5 + rawCorpus LONGTEXT NOT NULL COLLATE {$COLLATE_SORT}, 6 + termCorpus LONGTEXT NOT NULL COLLATE {$COLLATE_SORT}, 7 + normalCorpus LONGTEXT NOT NULL COLLATE {$COLLATE_SORT} 8 + ) ENGINE=InnoDB, COLLATE {$COLLATE_TEXT};
+5
resources/sql/autopatches/20170907.ferret.03.user.ngrams.sql
··· 1 + CREATE TABLE {$NAMESPACE}_user.user_user_fngrams ( 2 + id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, 3 + documentID INT UNSIGNED NOT NULL, 4 + ngram CHAR(3) NOT NULL COLLATE {$COLLATE_TEXT} 5 + ) ENGINE=InnoDB, COLLATE {$COLLATE_TEXT};
+9
src/__phutil_library_map__.php
··· 4257 4257 'PhabricatorUserEditorTestCase' => 'applications/people/editor/__tests__/PhabricatorUserEditorTestCase.php', 4258 4258 'PhabricatorUserEmail' => 'applications/people/storage/PhabricatorUserEmail.php', 4259 4259 'PhabricatorUserEmailTestCase' => 'applications/people/storage/__tests__/PhabricatorUserEmailTestCase.php', 4260 + 'PhabricatorUserFerretDocument' => 'applications/people/storage/PhabricatorUserFerretDocument.php', 4261 + 'PhabricatorUserFerretEngine' => 'applications/people/search/PhabricatorUserFerretEngine.php', 4262 + 'PhabricatorUserFerretField' => 'applications/people/storage/PhabricatorUserFerretField.php', 4263 + 'PhabricatorUserFerretNgrams' => 'applications/people/storage/PhabricatorUserFerretNgrams.php', 4260 4264 'PhabricatorUserFulltextEngine' => 'applications/people/search/PhabricatorUserFulltextEngine.php', 4261 4265 'PhabricatorUserIconField' => 'applications/people/customfield/PhabricatorUserIconField.php', 4262 4266 'PhabricatorUserLog' => 'applications/people/storage/PhabricatorUserLog.php', ··· 9840 9844 'PhabricatorFlaggableInterface', 9841 9845 'PhabricatorApplicationTransactionInterface', 9842 9846 'PhabricatorFulltextInterface', 9847 + 'PhabricatorFerretInterface', 9843 9848 'PhabricatorConduitResultInterface', 9844 9849 ), 9845 9850 'PhabricatorUserBadgesCacheType' => 'PhabricatorUserCacheType', ··· 9862 9867 'PhabricatorUserEditorTestCase' => 'PhabricatorTestCase', 9863 9868 'PhabricatorUserEmail' => 'PhabricatorUserDAO', 9864 9869 'PhabricatorUserEmailTestCase' => 'PhabricatorTestCase', 9870 + 'PhabricatorUserFerretDocument' => 'PhabricatorFerretDocument', 9871 + 'PhabricatorUserFerretEngine' => 'PhabricatorFerretEngine', 9872 + 'PhabricatorUserFerretField' => 'PhabricatorFerretField', 9873 + 'PhabricatorUserFerretNgrams' => 'PhabricatorFerretNgrams', 9865 9874 'PhabricatorUserFulltextEngine' => 'PhabricatorFulltextEngine', 9866 9875 'PhabricatorUserIconField' => 'PhabricatorUserCustomField', 9867 9876 'PhabricatorUserLog' => array(
+29
src/applications/people/search/PhabricatorUserFerretEngine.php
··· 1 + <?php 2 + 3 + final class PhabricatorUserFerretEngine 4 + extends PhabricatorFerretEngine { 5 + 6 + public function newNgramsObject() { 7 + return new PhabricatorUserFerretNgrams(); 8 + } 9 + 10 + public function newDocumentObject() { 11 + return new PhabricatorUserFerretDocument(); 12 + } 13 + 14 + public function newFieldObject() { 15 + return new PhabricatorUserFerretField(); 16 + } 17 + 18 + public function newSearchEngine() { 19 + return new PhabricatorPeopleSearchEngine(); 20 + } 21 + 22 + public function getObjectTypeRelevance() { 23 + // Always sort users above other documents, regardless of relevance 24 + // metrics. A user profile is very likely to be the best hit for a query 25 + // which matches a user. 26 + return 500; 27 + } 28 + 29 + }
+9
src/applications/people/storage/PhabricatorUser.php
··· 19 19 PhabricatorFlaggableInterface, 20 20 PhabricatorApplicationTransactionInterface, 21 21 PhabricatorFulltextInterface, 22 + PhabricatorFerretInterface, 22 23 PhabricatorConduitResultInterface { 23 24 24 25 const SESSION_TABLE = 'phabricator_session'; ··· 1431 1432 1432 1433 public function newFulltextEngine() { 1433 1434 return new PhabricatorUserFulltextEngine(); 1435 + } 1436 + 1437 + 1438 + /* -( PhabricatorFerretInterface )----------------------------------------- */ 1439 + 1440 + 1441 + public function newFerretEngine() { 1442 + return new PhabricatorUserFerretEngine(); 1434 1443 } 1435 1444 1436 1445
+14
src/applications/people/storage/PhabricatorUserFerretDocument.php
··· 1 + <?php 2 + 3 + final class PhabricatorUserFerretDocument 4 + extends PhabricatorFerretDocument { 5 + 6 + public function getApplicationName() { 7 + return 'user'; 8 + } 9 + 10 + public function getIndexKey() { 11 + return 'user'; 12 + } 13 + 14 + }
+14
src/applications/people/storage/PhabricatorUserFerretField.php
··· 1 + <?php 2 + 3 + final class PhabricatorUserFerretField 4 + extends PhabricatorFerretField { 5 + 6 + public function getApplicationName() { 7 + return 'user'; 8 + } 9 + 10 + public function getIndexKey() { 11 + return 'user'; 12 + } 13 + 14 + }
+14
src/applications/people/storage/PhabricatorUserFerretNgrams.php
··· 1 + <?php 2 + 3 + final class PhabricatorUserFerretNgrams 4 + extends PhabricatorFerretNgrams { 5 + 6 + public function getApplicationName() { 7 + return 'user'; 8 + } 9 + 10 + public function getIndexKey() { 11 + return 'user'; 12 + } 13 + 14 + }
+4
src/applications/search/ferret/PhabricatorFerretEngine.php
··· 11 11 return 'all'; 12 12 } 13 13 14 + public function getObjectTypeRelevance() { 15 + return 1000; 16 + } 17 + 14 18 public function getFieldForFunction($function) { 15 19 $function = phutil_utf8_strtolower($function); 16 20
+3
src/applications/search/ferret/PhabricatorFerretMetadata.php
··· 34 34 } 35 35 36 36 public function getRelevanceSortVector() { 37 + $engine = $this->getEngine(); 38 + 37 39 return id(new PhutilSortVector()) 40 + ->addInt($engine->getObjectTypeRelevance()) 38 41 ->addInt(-$this->getRelevance()); 39 42 } 40 43