1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-03-15 22:04:57 +01:00

Remove FIELD_KEYWORDS, index project slugs as body content

Summary:
D17384 added a "keywords" field but only partially implemented it.

  - Remove this field.
  - Index project slugs as part of the document body instead.

Test Plan:
  - Ran `bin/search index PHID-PROJ-... --force`.
  - Found project by searching for a unique slug.

Reviewers: chad, 20after4

Reviewed By: chad

Differential Revision: https://secure.phabricator.com/D17596
This commit is contained in:
epriestley 2017-04-02 08:43:02 -07:00
parent 515cb98819
commit 64234535e3
2 changed files with 17 additions and 9 deletions

View file

@ -8,17 +8,26 @@ final class PhabricatorProjectFulltextEngine
$object) {
$project = $object;
$viewer = $this->getViewer();
// Reload the project to get slugs.
$project = id(new PhabricatorProjectQuery())
->withIDs(array($project->getID()))
->setViewer($viewer)
->needSlugs(true)
->executeOne();
$project->updateDatasourceTokens();
$document->setDocumentTitle($project->getDisplayName());
$document->addField(PhabricatorSearchDocumentFieldType::FIELD_KEYWORDS,
$project->getPrimarySlug());
try {
$slugs = $project->getSlugs();
foreach ($slugs as $slug) {}
} catch (PhabricatorDataNotAttachedException $e) {
// ignore
$slugs = array();
foreach ($project->getSlugs() as $slug) {
$slugs[] = $slug->getSlug();
}
$body = implode("\n", $slugs);
$document
->setDocumentTitle($project->getDisplayName())
->addField(PhabricatorSearchDocumentFieldType::FIELD_BODY, $body);
$document->addRelationship(
$project->isArchived()

View file

@ -5,6 +5,5 @@ final class PhabricatorSearchDocumentFieldType extends Phobject {
const FIELD_TITLE = 'titl';
const FIELD_BODY = 'body';
const FIELD_COMMENT = 'cmnt';
const FIELD_KEYWORDS = 'kwrd';
}