From 64234535e3c96e7c60ce86815b25b592e7ab8a41 Mon Sep 17 00:00:00 2001 From: epriestley Date: Sun, 2 Apr 2017 08:43:02 -0700 Subject: [PATCH] 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 --- .../PhabricatorProjectFulltextEngine.php | 25 +++++++++++++------ .../PhabricatorSearchDocumentFieldType.php | 1 - 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/applications/project/search/PhabricatorProjectFulltextEngine.php b/src/applications/project/search/PhabricatorProjectFulltextEngine.php index 14314c3436..ecec952990 100644 --- a/src/applications/project/search/PhabricatorProjectFulltextEngine.php +++ b/src/applications/project/search/PhabricatorProjectFulltextEngine.php @@ -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() diff --git a/src/applications/search/constants/PhabricatorSearchDocumentFieldType.php b/src/applications/search/constants/PhabricatorSearchDocumentFieldType.php index 12c90f8469..10dbf0ca65 100644 --- a/src/applications/search/constants/PhabricatorSearchDocumentFieldType.php +++ b/src/applications/search/constants/PhabricatorSearchDocumentFieldType.php @@ -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'; }