1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-23 05:50:55 +01:00

Support Ferret engine in Phame

Summary: Ref T12819. Mostly straightforward, with a couple of minor query modernization things.

Test Plan: Indexed and searched for posts and blogs.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T12819

Differential Revision: https://secure.phabricator.com/D18565
This commit is contained in:
epriestley 2017-09-07 12:14:05 -07:00
parent c9152b586b
commit b1703c8801
13 changed files with 129 additions and 16 deletions

View file

@ -0,0 +1,9 @@
CREATE TABLE {$NAMESPACE}_phame.phame_blog_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};

View file

@ -0,0 +1,8 @@
CREATE TABLE {$NAMESPACE}_phame.phame_blog_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};

View file

@ -0,0 +1,5 @@
CREATE TABLE {$NAMESPACE}_phame.phame_blog_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};

View file

@ -0,0 +1,9 @@
CREATE TABLE {$NAMESPACE}_phame.phame_post_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};

View file

@ -0,0 +1,8 @@
CREATE TABLE {$NAMESPACE}_phame.phame_post_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};

View file

@ -0,0 +1,5 @@
CREATE TABLE {$NAMESPACE}_phame.phame_post_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};

View file

@ -4371,6 +4371,7 @@ phutil_register_library_map(array(
'PhameBlogEditEngine' => 'applications/phame/editor/PhameBlogEditEngine.php',
'PhameBlogEditor' => 'applications/phame/editor/PhameBlogEditor.php',
'PhameBlogFeedController' => 'applications/phame/controller/blog/PhameBlogFeedController.php',
'PhameBlogFerretEngine' => 'applications/phame/search/PhameBlogFerretEngine.php',
'PhameBlogFullDomainTransaction' => 'applications/phame/xaction/PhameBlogFullDomainTransaction.php',
'PhameBlogFulltextEngine' => 'applications/phame/search/PhameBlogFulltextEngine.php',
'PhameBlogHeaderImageTransaction' => 'applications/phame/xaction/PhameBlogHeaderImageTransaction.php',
@ -4411,6 +4412,7 @@ phutil_register_library_map(array(
'PhamePostEditController' => 'applications/phame/controller/post/PhamePostEditController.php',
'PhamePostEditEngine' => 'applications/phame/editor/PhamePostEditEngine.php',
'PhamePostEditor' => 'applications/phame/editor/PhamePostEditor.php',
'PhamePostFerretEngine' => 'applications/phame/search/PhamePostFerretEngine.php',
'PhamePostFulltextEngine' => 'applications/phame/search/PhamePostFulltextEngine.php',
'PhamePostHeaderImageTransaction' => 'applications/phame/xaction/PhamePostHeaderImageTransaction.php',
'PhamePostHeaderPictureController' => 'applications/phame/controller/post/PhamePostHeaderPictureController.php',
@ -9995,6 +9997,7 @@ phutil_register_library_map(array(
'PhabricatorApplicationTransactionInterface',
'PhabricatorConduitResultInterface',
'PhabricatorFulltextInterface',
'PhabricatorFerretInterface',
),
'PhameBlog404Controller' => 'PhameLiveController',
'PhameBlogArchiveController' => 'PhameBlogController',
@ -10007,6 +10010,7 @@ phutil_register_library_map(array(
'PhameBlogEditEngine' => 'PhabricatorEditEngine',
'PhameBlogEditor' => 'PhabricatorApplicationTransactionEditor',
'PhameBlogFeedController' => 'PhameBlogController',
'PhameBlogFerretEngine' => 'PhabricatorFerretEngine',
'PhameBlogFullDomainTransaction' => 'PhameBlogTransactionType',
'PhameBlogFulltextEngine' => 'PhabricatorFulltextEngine',
'PhameBlogHeaderImageTransaction' => 'PhameBlogTransactionType',
@ -10050,6 +10054,7 @@ phutil_register_library_map(array(
'PhabricatorTokenReceiverInterface',
'PhabricatorConduitResultInterface',
'PhabricatorFulltextInterface',
'PhabricatorFerretInterface',
),
'PhamePostArchiveController' => 'PhamePostController',
'PhamePostBlogTransaction' => 'PhamePostTransactionType',
@ -10059,6 +10064,7 @@ phutil_register_library_map(array(
'PhamePostEditController' => 'PhamePostController',
'PhamePostEditEngine' => 'PhabricatorEditEngine',
'PhamePostEditor' => 'PhabricatorApplicationTransactionEditor',
'PhamePostFerretEngine' => 'PhabricatorFerretEngine',
'PhamePostFulltextEngine' => 'PhabricatorFulltextEngine',
'PhamePostHeaderImageTransaction' => 'PhamePostTransactionType',
'PhamePostHeaderPictureController' => 'PhamePostController',

View file

@ -55,28 +55,28 @@ final class PhameBlogQuery extends PhabricatorCursorPagedPolicyAwareQuery {
if ($this->statuses !== null) {
$where[] = qsprintf(
$conn,
'status IN (%Ls)',
'b.status IN (%Ls)',
$this->statuses);
}
if ($this->ids !== null) {
$where[] = qsprintf(
$conn,
'id IN (%Ls)',
'b.id IN (%Ls)',
$this->ids);
}
if ($this->phids !== null) {
$where[] = qsprintf(
$conn,
'phid IN (%Ls)',
'b.phid IN (%Ls)',
$this->phids);
}
if ($this->domain !== null) {
$where[] = qsprintf(
$conn,
'domain = %s',
'b.domain = %s',
$this->domain);
}
@ -143,4 +143,8 @@ final class PhameBlogQuery extends PhabricatorCursorPagedPolicyAwareQuery {
return null;
}
protected function getPrimaryTableAlias() {
return 'b';
}
}

View file

@ -106,45 +106,45 @@ final class PhamePostQuery extends PhabricatorCursorPagedPolicyAwareQuery {
protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) {
$where = parent::buildWhereClauseParts($conn);
if ($this->ids) {
if ($this->ids !== null) {
$where[] = qsprintf(
$conn,
'id IN (%Ld)',
'p.id IN (%Ld)',
$this->ids);
}
if ($this->phids) {
if ($this->phids !== null) {
$where[] = qsprintf(
$conn,
'phid IN (%Ls)',
'p.phid IN (%Ls)',
$this->phids);
}
if ($this->bloggerPHIDs) {
if ($this->bloggerPHIDs !== null) {
$where[] = qsprintf(
$conn,
'bloggerPHID IN (%Ls)',
'p.bloggerPHID IN (%Ls)',
$this->bloggerPHIDs);
}
if ($this->visibility) {
if ($this->visibility !== null) {
$where[] = qsprintf(
$conn,
'visibility IN (%Ld)',
'p.visibility IN (%Ld)',
$this->visibility);
}
if ($this->publishedAfter !== null) {
$where[] = qsprintf(
$conn,
'datePublished > %d',
'p.datePublished > %d',
$this->publishedAfter);
}
if ($this->blogPHIDs !== null) {
$where[] = qsprintf(
$conn,
'blogPHID in (%Ls)',
'p.blogPHID in (%Ls)',
$this->blogPHIDs);
}
@ -163,6 +163,7 @@ final class PhamePostQuery extends PhabricatorCursorPagedPolicyAwareQuery {
public function getOrderableColumns() {
return parent::getOrderableColumns() + array(
'datePublished' => array(
'table' => $this->getPrimaryTableAlias(),
'column' => 'datePublished',
'type' => 'int',
'reverse' => false,
@ -186,4 +187,8 @@ final class PhamePostQuery extends PhabricatorCursorPagedPolicyAwareQuery {
return null;
}
protected function getPrimaryTableAlias() {
return 'p';
}
}

View file

@ -0,0 +1,18 @@
<?php
final class PhameBlogFerretEngine
extends PhabricatorFerretEngine {
public function getApplicationName() {
return 'phame';
}
public function getScopeName() {
return 'blog';
}
public function newSearchEngine() {
return new PhameBlogSearchEngine();
}
}

View file

@ -0,0 +1,18 @@
<?php
final class PhamePostFerretEngine
extends PhabricatorFerretEngine {
public function getApplicationName() {
return 'phame';
}
public function getScopeName() {
return 'post';
}
public function newSearchEngine() {
return new PhamePostSearchEngine();
}
}

View file

@ -10,7 +10,8 @@ final class PhameBlog extends PhameDAO
PhabricatorDestructibleInterface,
PhabricatorApplicationTransactionInterface,
PhabricatorConduitResultInterface,
PhabricatorFulltextInterface {
PhabricatorFulltextInterface,
PhabricatorFerretInterface {
const MARKUP_FIELD_DESCRIPTION = 'markup:description';
@ -392,4 +393,12 @@ final class PhameBlog extends PhameDAO
return new PhameBlogFulltextEngine();
}
/* -( PhabricatorFerretInterface )----------------------------------------- */
public function newFerretEngine() {
return new PhameBlogFerretEngine();
}
}

View file

@ -11,7 +11,8 @@ final class PhamePost extends PhameDAO
PhabricatorDestructibleInterface,
PhabricatorTokenReceiverInterface,
PhabricatorConduitResultInterface,
PhabricatorFulltextInterface {
PhabricatorFulltextInterface,
PhabricatorFerretInterface {
const MARKUP_FIELD_BODY = 'markup:body';
const MARKUP_FIELD_SUMMARY = 'markup:summary';
@ -387,4 +388,12 @@ final class PhamePost extends PhameDAO
return new PhamePostFulltextEngine();
}
/* -( PhabricatorFerretInterface )----------------------------------------- */
public function newFerretEngine() {
return new PhamePostFerretEngine();
}
}