1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-01 11:12:42 +01:00
phorge-phorge/src/applications/diviner/search/DivinerAtomSearchIndexer.php
Joshua Spence 600a3e3b7c Only index documentable atoms for search
Summary: Ref T7458. Only index documentable atoms in the search index. In particular, this prevents files and methods from being returned in search results (clicking on these search results doesn't actually work anyway).

Test Plan: Actually, to get this to work I had to destroy the search index and recreate it... is this expected?

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

Maniphest Tasks: T7458

Differential Revision: https://secure.phabricator.com/D13298
2015-06-16 06:52:19 +10:00

35 lines
868 B
PHP

<?php
final class DivinerAtomSearchIndexer extends PhabricatorSearchDocumentIndexer {
public function getIndexableObject() {
return new DivinerLiveSymbol();
}
protected function buildAbstractDocumentByPHID($phid) {
$atom = $this->loadDocumentByPHID($phid);
$book = $atom->getBook();
if (!$atom->getIsDocumentable()) {
return null;
}
$doc = $this->newDocument($phid)
->setDocumentTitle($atom->getTitle())
->setDocumentCreated($book->getDateCreated())
->setDocumentModified($book->getDateModified());
$doc->addField(
PhabricatorSearchDocumentFieldType::FIELD_BODY,
$atom->getSummary());
$doc->addRelationship(
PhabricatorSearchRelationship::RELATIONSHIP_BOOK,
$atom->getBookPHID(),
DivinerBookPHIDType::TYPECONST,
$book->getDateCreated());
return $doc;
}
}