Page MenuHomePhabricator

D18552.diff
No OneTemporary

D18552.diff

diff --git a/resources/sql/autopatches/20170907.ferret.01.user.doc.sql b/resources/sql/autopatches/20170907.ferret.01.user.doc.sql
new file mode 100644
--- /dev/null
+++ b/resources/sql/autopatches/20170907.ferret.01.user.doc.sql
@@ -0,0 +1,9 @@
+CREATE TABLE {$NAMESPACE}_user.user_user_fdocument (
+ id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
+ objectPHID VARBINARY(64) NOT NULL,
+ isClosed BOOL NOT NULL,
+ authorPHID VARBINARY(64),
+ ownerPHID VARBINARY(64),
+ epochCreated INT UNSIGNED NOT NULL,
+ epochModified INT UNSIGNED NOT NULL
+) ENGINE=InnoDB, COLLATE {$COLLATE_TEXT};
diff --git a/resources/sql/autopatches/20170907.ferret.02.user.field.sql b/resources/sql/autopatches/20170907.ferret.02.user.field.sql
new file mode 100644
--- /dev/null
+++ b/resources/sql/autopatches/20170907.ferret.02.user.field.sql
@@ -0,0 +1,8 @@
+CREATE TABLE {$NAMESPACE}_user.user_user_ffield (
+ id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
+ documentID INT UNSIGNED NOT NULL,
+ fieldKey VARCHAR(4) NOT NULL COLLATE {$COLLATE_TEXT},
+ rawCorpus LONGTEXT NOT NULL COLLATE {$COLLATE_SORT},
+ termCorpus LONGTEXT NOT NULL COLLATE {$COLLATE_SORT},
+ normalCorpus LONGTEXT NOT NULL COLLATE {$COLLATE_SORT}
+) ENGINE=InnoDB, COLLATE {$COLLATE_TEXT};
diff --git a/resources/sql/autopatches/20170907.ferret.03.user.ngrams.sql b/resources/sql/autopatches/20170907.ferret.03.user.ngrams.sql
new file mode 100644
--- /dev/null
+++ b/resources/sql/autopatches/20170907.ferret.03.user.ngrams.sql
@@ -0,0 +1,5 @@
+CREATE TABLE {$NAMESPACE}_user.user_user_fngrams (
+ id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
+ documentID INT UNSIGNED NOT NULL,
+ ngram CHAR(3) NOT NULL COLLATE {$COLLATE_TEXT}
+) ENGINE=InnoDB, COLLATE {$COLLATE_TEXT};
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
@@ -4257,6 +4257,10 @@
'PhabricatorUserEditorTestCase' => 'applications/people/editor/__tests__/PhabricatorUserEditorTestCase.php',
'PhabricatorUserEmail' => 'applications/people/storage/PhabricatorUserEmail.php',
'PhabricatorUserEmailTestCase' => 'applications/people/storage/__tests__/PhabricatorUserEmailTestCase.php',
+ 'PhabricatorUserFerretDocument' => 'applications/people/storage/PhabricatorUserFerretDocument.php',
+ 'PhabricatorUserFerretEngine' => 'applications/people/search/PhabricatorUserFerretEngine.php',
+ 'PhabricatorUserFerretField' => 'applications/people/storage/PhabricatorUserFerretField.php',
+ 'PhabricatorUserFerretNgrams' => 'applications/people/storage/PhabricatorUserFerretNgrams.php',
'PhabricatorUserFulltextEngine' => 'applications/people/search/PhabricatorUserFulltextEngine.php',
'PhabricatorUserIconField' => 'applications/people/customfield/PhabricatorUserIconField.php',
'PhabricatorUserLog' => 'applications/people/storage/PhabricatorUserLog.php',
@@ -9840,6 +9844,7 @@
'PhabricatorFlaggableInterface',
'PhabricatorApplicationTransactionInterface',
'PhabricatorFulltextInterface',
+ 'PhabricatorFerretInterface',
'PhabricatorConduitResultInterface',
),
'PhabricatorUserBadgesCacheType' => 'PhabricatorUserCacheType',
@@ -9862,6 +9867,10 @@
'PhabricatorUserEditorTestCase' => 'PhabricatorTestCase',
'PhabricatorUserEmail' => 'PhabricatorUserDAO',
'PhabricatorUserEmailTestCase' => 'PhabricatorTestCase',
+ 'PhabricatorUserFerretDocument' => 'PhabricatorFerretDocument',
+ 'PhabricatorUserFerretEngine' => 'PhabricatorFerretEngine',
+ 'PhabricatorUserFerretField' => 'PhabricatorFerretField',
+ 'PhabricatorUserFerretNgrams' => 'PhabricatorFerretNgrams',
'PhabricatorUserFulltextEngine' => 'PhabricatorFulltextEngine',
'PhabricatorUserIconField' => 'PhabricatorUserCustomField',
'PhabricatorUserLog' => array(
diff --git a/src/applications/people/search/PhabricatorUserFerretEngine.php b/src/applications/people/search/PhabricatorUserFerretEngine.php
new file mode 100644
--- /dev/null
+++ b/src/applications/people/search/PhabricatorUserFerretEngine.php
@@ -0,0 +1,29 @@
+<?php
+
+final class PhabricatorUserFerretEngine
+ extends PhabricatorFerretEngine {
+
+ public function newNgramsObject() {
+ return new PhabricatorUserFerretNgrams();
+ }
+
+ public function newDocumentObject() {
+ return new PhabricatorUserFerretDocument();
+ }
+
+ public function newFieldObject() {
+ return new PhabricatorUserFerretField();
+ }
+
+ public function newSearchEngine() {
+ return new PhabricatorPeopleSearchEngine();
+ }
+
+ public function getObjectTypeRelevance() {
+ // Always sort users above other documents, regardless of relevance
+ // metrics. A user profile is very likely to be the best hit for a query
+ // which matches a user.
+ return 500;
+ }
+
+}
diff --git a/src/applications/people/storage/PhabricatorUser.php b/src/applications/people/storage/PhabricatorUser.php
--- a/src/applications/people/storage/PhabricatorUser.php
+++ b/src/applications/people/storage/PhabricatorUser.php
@@ -19,6 +19,7 @@
PhabricatorFlaggableInterface,
PhabricatorApplicationTransactionInterface,
PhabricatorFulltextInterface,
+ PhabricatorFerretInterface,
PhabricatorConduitResultInterface {
const SESSION_TABLE = 'phabricator_session';
@@ -1434,6 +1435,14 @@
}
+/* -( PhabricatorFerretInterface )----------------------------------------- */
+
+
+ public function newFerretEngine() {
+ return new PhabricatorUserFerretEngine();
+ }
+
+
/* -( PhabricatorConduitResultInterface )---------------------------------- */
diff --git a/src/applications/people/storage/PhabricatorUserFerretDocument.php b/src/applications/people/storage/PhabricatorUserFerretDocument.php
new file mode 100644
--- /dev/null
+++ b/src/applications/people/storage/PhabricatorUserFerretDocument.php
@@ -0,0 +1,14 @@
+<?php
+
+final class PhabricatorUserFerretDocument
+ extends PhabricatorFerretDocument {
+
+ public function getApplicationName() {
+ return 'user';
+ }
+
+ public function getIndexKey() {
+ return 'user';
+ }
+
+}
diff --git a/src/applications/people/storage/PhabricatorUserFerretField.php b/src/applications/people/storage/PhabricatorUserFerretField.php
new file mode 100644
--- /dev/null
+++ b/src/applications/people/storage/PhabricatorUserFerretField.php
@@ -0,0 +1,14 @@
+<?php
+
+final class PhabricatorUserFerretField
+ extends PhabricatorFerretField {
+
+ public function getApplicationName() {
+ return 'user';
+ }
+
+ public function getIndexKey() {
+ return 'user';
+ }
+
+}
diff --git a/src/applications/people/storage/PhabricatorUserFerretNgrams.php b/src/applications/people/storage/PhabricatorUserFerretNgrams.php
new file mode 100644
--- /dev/null
+++ b/src/applications/people/storage/PhabricatorUserFerretNgrams.php
@@ -0,0 +1,14 @@
+<?php
+
+final class PhabricatorUserFerretNgrams
+ extends PhabricatorFerretNgrams {
+
+ public function getApplicationName() {
+ return 'user';
+ }
+
+ public function getIndexKey() {
+ return 'user';
+ }
+
+}
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
@@ -11,6 +11,10 @@
return 'all';
}
+ public function getObjectTypeRelevance() {
+ return 1000;
+ }
+
public function getFieldForFunction($function) {
$function = phutil_utf8_strtolower($function);
diff --git a/src/applications/search/ferret/PhabricatorFerretMetadata.php b/src/applications/search/ferret/PhabricatorFerretMetadata.php
--- a/src/applications/search/ferret/PhabricatorFerretMetadata.php
+++ b/src/applications/search/ferret/PhabricatorFerretMetadata.php
@@ -34,7 +34,10 @@
}
public function getRelevanceSortVector() {
+ $engine = $this->getEngine();
+
return id(new PhutilSortVector())
+ ->addInt($engine->getObjectTypeRelevance())
->addInt(-$this->getRelevance());
}

File Metadata

Mime Type
text/plain
Expires
Thu, May 9, 8:18 PM (1 w, 6 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6276607
Default Alt Text
D18552.diff (7 KB)

Event Timeline