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:
parent
c9152b586b
commit
b1703c8801
13 changed files with 129 additions and 16 deletions
|
@ -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};
|
|
@ -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};
|
|
@ -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};
|
|
@ -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};
|
|
@ -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};
|
|
@ -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};
|
|
@ -4371,6 +4371,7 @@ phutil_register_library_map(array(
|
||||||
'PhameBlogEditEngine' => 'applications/phame/editor/PhameBlogEditEngine.php',
|
'PhameBlogEditEngine' => 'applications/phame/editor/PhameBlogEditEngine.php',
|
||||||
'PhameBlogEditor' => 'applications/phame/editor/PhameBlogEditor.php',
|
'PhameBlogEditor' => 'applications/phame/editor/PhameBlogEditor.php',
|
||||||
'PhameBlogFeedController' => 'applications/phame/controller/blog/PhameBlogFeedController.php',
|
'PhameBlogFeedController' => 'applications/phame/controller/blog/PhameBlogFeedController.php',
|
||||||
|
'PhameBlogFerretEngine' => 'applications/phame/search/PhameBlogFerretEngine.php',
|
||||||
'PhameBlogFullDomainTransaction' => 'applications/phame/xaction/PhameBlogFullDomainTransaction.php',
|
'PhameBlogFullDomainTransaction' => 'applications/phame/xaction/PhameBlogFullDomainTransaction.php',
|
||||||
'PhameBlogFulltextEngine' => 'applications/phame/search/PhameBlogFulltextEngine.php',
|
'PhameBlogFulltextEngine' => 'applications/phame/search/PhameBlogFulltextEngine.php',
|
||||||
'PhameBlogHeaderImageTransaction' => 'applications/phame/xaction/PhameBlogHeaderImageTransaction.php',
|
'PhameBlogHeaderImageTransaction' => 'applications/phame/xaction/PhameBlogHeaderImageTransaction.php',
|
||||||
|
@ -4411,6 +4412,7 @@ phutil_register_library_map(array(
|
||||||
'PhamePostEditController' => 'applications/phame/controller/post/PhamePostEditController.php',
|
'PhamePostEditController' => 'applications/phame/controller/post/PhamePostEditController.php',
|
||||||
'PhamePostEditEngine' => 'applications/phame/editor/PhamePostEditEngine.php',
|
'PhamePostEditEngine' => 'applications/phame/editor/PhamePostEditEngine.php',
|
||||||
'PhamePostEditor' => 'applications/phame/editor/PhamePostEditor.php',
|
'PhamePostEditor' => 'applications/phame/editor/PhamePostEditor.php',
|
||||||
|
'PhamePostFerretEngine' => 'applications/phame/search/PhamePostFerretEngine.php',
|
||||||
'PhamePostFulltextEngine' => 'applications/phame/search/PhamePostFulltextEngine.php',
|
'PhamePostFulltextEngine' => 'applications/phame/search/PhamePostFulltextEngine.php',
|
||||||
'PhamePostHeaderImageTransaction' => 'applications/phame/xaction/PhamePostHeaderImageTransaction.php',
|
'PhamePostHeaderImageTransaction' => 'applications/phame/xaction/PhamePostHeaderImageTransaction.php',
|
||||||
'PhamePostHeaderPictureController' => 'applications/phame/controller/post/PhamePostHeaderPictureController.php',
|
'PhamePostHeaderPictureController' => 'applications/phame/controller/post/PhamePostHeaderPictureController.php',
|
||||||
|
@ -9995,6 +9997,7 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorApplicationTransactionInterface',
|
'PhabricatorApplicationTransactionInterface',
|
||||||
'PhabricatorConduitResultInterface',
|
'PhabricatorConduitResultInterface',
|
||||||
'PhabricatorFulltextInterface',
|
'PhabricatorFulltextInterface',
|
||||||
|
'PhabricatorFerretInterface',
|
||||||
),
|
),
|
||||||
'PhameBlog404Controller' => 'PhameLiveController',
|
'PhameBlog404Controller' => 'PhameLiveController',
|
||||||
'PhameBlogArchiveController' => 'PhameBlogController',
|
'PhameBlogArchiveController' => 'PhameBlogController',
|
||||||
|
@ -10007,6 +10010,7 @@ phutil_register_library_map(array(
|
||||||
'PhameBlogEditEngine' => 'PhabricatorEditEngine',
|
'PhameBlogEditEngine' => 'PhabricatorEditEngine',
|
||||||
'PhameBlogEditor' => 'PhabricatorApplicationTransactionEditor',
|
'PhameBlogEditor' => 'PhabricatorApplicationTransactionEditor',
|
||||||
'PhameBlogFeedController' => 'PhameBlogController',
|
'PhameBlogFeedController' => 'PhameBlogController',
|
||||||
|
'PhameBlogFerretEngine' => 'PhabricatorFerretEngine',
|
||||||
'PhameBlogFullDomainTransaction' => 'PhameBlogTransactionType',
|
'PhameBlogFullDomainTransaction' => 'PhameBlogTransactionType',
|
||||||
'PhameBlogFulltextEngine' => 'PhabricatorFulltextEngine',
|
'PhameBlogFulltextEngine' => 'PhabricatorFulltextEngine',
|
||||||
'PhameBlogHeaderImageTransaction' => 'PhameBlogTransactionType',
|
'PhameBlogHeaderImageTransaction' => 'PhameBlogTransactionType',
|
||||||
|
@ -10050,6 +10054,7 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorTokenReceiverInterface',
|
'PhabricatorTokenReceiverInterface',
|
||||||
'PhabricatorConduitResultInterface',
|
'PhabricatorConduitResultInterface',
|
||||||
'PhabricatorFulltextInterface',
|
'PhabricatorFulltextInterface',
|
||||||
|
'PhabricatorFerretInterface',
|
||||||
),
|
),
|
||||||
'PhamePostArchiveController' => 'PhamePostController',
|
'PhamePostArchiveController' => 'PhamePostController',
|
||||||
'PhamePostBlogTransaction' => 'PhamePostTransactionType',
|
'PhamePostBlogTransaction' => 'PhamePostTransactionType',
|
||||||
|
@ -10059,6 +10064,7 @@ phutil_register_library_map(array(
|
||||||
'PhamePostEditController' => 'PhamePostController',
|
'PhamePostEditController' => 'PhamePostController',
|
||||||
'PhamePostEditEngine' => 'PhabricatorEditEngine',
|
'PhamePostEditEngine' => 'PhabricatorEditEngine',
|
||||||
'PhamePostEditor' => 'PhabricatorApplicationTransactionEditor',
|
'PhamePostEditor' => 'PhabricatorApplicationTransactionEditor',
|
||||||
|
'PhamePostFerretEngine' => 'PhabricatorFerretEngine',
|
||||||
'PhamePostFulltextEngine' => 'PhabricatorFulltextEngine',
|
'PhamePostFulltextEngine' => 'PhabricatorFulltextEngine',
|
||||||
'PhamePostHeaderImageTransaction' => 'PhamePostTransactionType',
|
'PhamePostHeaderImageTransaction' => 'PhamePostTransactionType',
|
||||||
'PhamePostHeaderPictureController' => 'PhamePostController',
|
'PhamePostHeaderPictureController' => 'PhamePostController',
|
||||||
|
|
|
@ -55,28 +55,28 @@ final class PhameBlogQuery extends PhabricatorCursorPagedPolicyAwareQuery {
|
||||||
if ($this->statuses !== null) {
|
if ($this->statuses !== null) {
|
||||||
$where[] = qsprintf(
|
$where[] = qsprintf(
|
||||||
$conn,
|
$conn,
|
||||||
'status IN (%Ls)',
|
'b.status IN (%Ls)',
|
||||||
$this->statuses);
|
$this->statuses);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->ids !== null) {
|
if ($this->ids !== null) {
|
||||||
$where[] = qsprintf(
|
$where[] = qsprintf(
|
||||||
$conn,
|
$conn,
|
||||||
'id IN (%Ls)',
|
'b.id IN (%Ls)',
|
||||||
$this->ids);
|
$this->ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->phids !== null) {
|
if ($this->phids !== null) {
|
||||||
$where[] = qsprintf(
|
$where[] = qsprintf(
|
||||||
$conn,
|
$conn,
|
||||||
'phid IN (%Ls)',
|
'b.phid IN (%Ls)',
|
||||||
$this->phids);
|
$this->phids);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->domain !== null) {
|
if ($this->domain !== null) {
|
||||||
$where[] = qsprintf(
|
$where[] = qsprintf(
|
||||||
$conn,
|
$conn,
|
||||||
'domain = %s',
|
'b.domain = %s',
|
||||||
$this->domain);
|
$this->domain);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -143,4 +143,8 @@ final class PhameBlogQuery extends PhabricatorCursorPagedPolicyAwareQuery {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function getPrimaryTableAlias() {
|
||||||
|
return 'b';
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -106,45 +106,45 @@ final class PhamePostQuery extends PhabricatorCursorPagedPolicyAwareQuery {
|
||||||
protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) {
|
protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) {
|
||||||
$where = parent::buildWhereClauseParts($conn);
|
$where = parent::buildWhereClauseParts($conn);
|
||||||
|
|
||||||
if ($this->ids) {
|
if ($this->ids !== null) {
|
||||||
$where[] = qsprintf(
|
$where[] = qsprintf(
|
||||||
$conn,
|
$conn,
|
||||||
'id IN (%Ld)',
|
'p.id IN (%Ld)',
|
||||||
$this->ids);
|
$this->ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->phids) {
|
if ($this->phids !== null) {
|
||||||
$where[] = qsprintf(
|
$where[] = qsprintf(
|
||||||
$conn,
|
$conn,
|
||||||
'phid IN (%Ls)',
|
'p.phid IN (%Ls)',
|
||||||
$this->phids);
|
$this->phids);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->bloggerPHIDs) {
|
if ($this->bloggerPHIDs !== null) {
|
||||||
$where[] = qsprintf(
|
$where[] = qsprintf(
|
||||||
$conn,
|
$conn,
|
||||||
'bloggerPHID IN (%Ls)',
|
'p.bloggerPHID IN (%Ls)',
|
||||||
$this->bloggerPHIDs);
|
$this->bloggerPHIDs);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->visibility) {
|
if ($this->visibility !== null) {
|
||||||
$where[] = qsprintf(
|
$where[] = qsprintf(
|
||||||
$conn,
|
$conn,
|
||||||
'visibility IN (%Ld)',
|
'p.visibility IN (%Ld)',
|
||||||
$this->visibility);
|
$this->visibility);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->publishedAfter !== null) {
|
if ($this->publishedAfter !== null) {
|
||||||
$where[] = qsprintf(
|
$where[] = qsprintf(
|
||||||
$conn,
|
$conn,
|
||||||
'datePublished > %d',
|
'p.datePublished > %d',
|
||||||
$this->publishedAfter);
|
$this->publishedAfter);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->blogPHIDs !== null) {
|
if ($this->blogPHIDs !== null) {
|
||||||
$where[] = qsprintf(
|
$where[] = qsprintf(
|
||||||
$conn,
|
$conn,
|
||||||
'blogPHID in (%Ls)',
|
'p.blogPHID in (%Ls)',
|
||||||
$this->blogPHIDs);
|
$this->blogPHIDs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -163,6 +163,7 @@ final class PhamePostQuery extends PhabricatorCursorPagedPolicyAwareQuery {
|
||||||
public function getOrderableColumns() {
|
public function getOrderableColumns() {
|
||||||
return parent::getOrderableColumns() + array(
|
return parent::getOrderableColumns() + array(
|
||||||
'datePublished' => array(
|
'datePublished' => array(
|
||||||
|
'table' => $this->getPrimaryTableAlias(),
|
||||||
'column' => 'datePublished',
|
'column' => 'datePublished',
|
||||||
'type' => 'int',
|
'type' => 'int',
|
||||||
'reverse' => false,
|
'reverse' => false,
|
||||||
|
@ -186,4 +187,8 @@ final class PhamePostQuery extends PhabricatorCursorPagedPolicyAwareQuery {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function getPrimaryTableAlias() {
|
||||||
|
return 'p';
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
18
src/applications/phame/search/PhameBlogFerretEngine.php
Normal file
18
src/applications/phame/search/PhameBlogFerretEngine.php
Normal 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();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
18
src/applications/phame/search/PhamePostFerretEngine.php
Normal file
18
src/applications/phame/search/PhamePostFerretEngine.php
Normal 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();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -10,7 +10,8 @@ final class PhameBlog extends PhameDAO
|
||||||
PhabricatorDestructibleInterface,
|
PhabricatorDestructibleInterface,
|
||||||
PhabricatorApplicationTransactionInterface,
|
PhabricatorApplicationTransactionInterface,
|
||||||
PhabricatorConduitResultInterface,
|
PhabricatorConduitResultInterface,
|
||||||
PhabricatorFulltextInterface {
|
PhabricatorFulltextInterface,
|
||||||
|
PhabricatorFerretInterface {
|
||||||
|
|
||||||
const MARKUP_FIELD_DESCRIPTION = 'markup:description';
|
const MARKUP_FIELD_DESCRIPTION = 'markup:description';
|
||||||
|
|
||||||
|
@ -392,4 +393,12 @@ final class PhameBlog extends PhameDAO
|
||||||
return new PhameBlogFulltextEngine();
|
return new PhameBlogFulltextEngine();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* -( PhabricatorFerretInterface )----------------------------------------- */
|
||||||
|
|
||||||
|
|
||||||
|
public function newFerretEngine() {
|
||||||
|
return new PhameBlogFerretEngine();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,8 @@ final class PhamePost extends PhameDAO
|
||||||
PhabricatorDestructibleInterface,
|
PhabricatorDestructibleInterface,
|
||||||
PhabricatorTokenReceiverInterface,
|
PhabricatorTokenReceiverInterface,
|
||||||
PhabricatorConduitResultInterface,
|
PhabricatorConduitResultInterface,
|
||||||
PhabricatorFulltextInterface {
|
PhabricatorFulltextInterface,
|
||||||
|
PhabricatorFerretInterface {
|
||||||
|
|
||||||
const MARKUP_FIELD_BODY = 'markup:body';
|
const MARKUP_FIELD_BODY = 'markup:body';
|
||||||
const MARKUP_FIELD_SUMMARY = 'markup:summary';
|
const MARKUP_FIELD_SUMMARY = 'markup:summary';
|
||||||
|
@ -387,4 +388,12 @@ final class PhamePost extends PhameDAO
|
||||||
return new PhamePostFulltextEngine();
|
return new PhamePostFulltextEngine();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* -( PhabricatorFerretInterface )----------------------------------------- */
|
||||||
|
|
||||||
|
|
||||||
|
public function newFerretEngine() {
|
||||||
|
return new PhamePostFerretEngine();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue