mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-10 08:52:39 +01:00
Rebuild custom field indexes when rebuilding standard/fulltext search indexes
Summary: Ref T4379. Fixes T4359. Currently, `bin/search index` does not rebuild CustomField indexes. This is because they aren't really part of the main search index. However, from a user's point of view this is by far the most logical place to look for index rebuilds, and it's straightforward for us to write into this secondary store. At some point, it might be nice to let you specify fields as "fulltext" too, although no one has asked for that yet. We could then dump the text of those fields into the fulltext index. Ref T418. Test Plan: Used `bin/search index --type proj --trace`, etc., and examination of the database to verify that indexes rebuilt. Reindexed users, tasks, projects. Reviewers: btrahan Reviewed By: btrahan CC: aran Maniphest Tasks: T4359, T418, T4379 Differential Revision: https://secure.phabricator.com/D8185
This commit is contained in:
parent
d70dd190e4
commit
fb9b023fba
5 changed files with 35 additions and 3 deletions
|
@ -81,6 +81,8 @@ final class ManiphestSearchIndexer
|
|||
time());
|
||||
}
|
||||
|
||||
$this->indexCustomFields($doc, $task);
|
||||
|
||||
return $doc;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,9 +17,6 @@ final class PhabricatorUserSearchIndexer
|
|||
$doc->setDocumentCreated($user->getDateCreated());
|
||||
$doc->setDocumentModified($user->getDateModified());
|
||||
|
||||
// TODO: Index the blurbs from their profile or something? Probably not
|
||||
// actually useful...
|
||||
|
||||
$doc->addRelationship(
|
||||
$user->isUserActivated()
|
||||
? PhabricatorSearchRelationship::RELATIONSHIP_OPEN
|
||||
|
@ -28,6 +25,8 @@ final class PhabricatorUserSearchIndexer
|
|||
PhabricatorPeoplePHIDTypeUser::TYPECONST,
|
||||
time());
|
||||
|
||||
$this->indexCustomFields($doc, $user);
|
||||
|
||||
return $doc;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,6 +17,9 @@ final class PhabricatorProjectSearchIndexer
|
|||
$doc->setDocumentCreated($project->getDateCreated());
|
||||
$doc->setDocumentModified($project->getDateModified());
|
||||
|
||||
$this->indexSubscribers($doc);
|
||||
$this->indexCustomFields($doc, $project);
|
||||
|
||||
// NOTE: This could be more full-featured, but for now we're mostly
|
||||
// interested in the side effects of indexing.
|
||||
|
||||
|
|
|
@ -106,6 +106,29 @@ abstract class PhabricatorSearchDocumentIndexer {
|
|||
}
|
||||
}
|
||||
|
||||
protected function indexCustomFields(
|
||||
PhabricatorSearchAbstractDocument $doc,
|
||||
PhabricatorCustomFieldInterface $object) {
|
||||
|
||||
// Rebuild the ApplicationSearch indexes. These are internal and not part of
|
||||
// the fulltext search, but putting them in this workflow allows users to
|
||||
// use the same tools to rebuild the indexes, which is easy to understand.
|
||||
|
||||
$field_list = PhabricatorCustomField::getObjectFields(
|
||||
$object,
|
||||
PhabricatorCustomField::ROLE_APPLICATIONSEARCH);
|
||||
|
||||
$field_list->setViewer($this->getViewer());
|
||||
$field_list->readFieldsFromStorage($object);
|
||||
$field_list->rebuildIndexes($object);
|
||||
|
||||
// We could also allow fields to provide fulltext content, and index it
|
||||
// here on the document. No one has asked for this yet, though, and the
|
||||
// existing "search" key isn't a good fit to interpret to mean we should
|
||||
// index stuff here, since it can be set on a lot of fields which don't
|
||||
// contain anything resembling fulltext.
|
||||
}
|
||||
|
||||
private function dispatchDidUpdateIndexEvent(
|
||||
$phid,
|
||||
PhabricatorSearchAbstractDocument $document) {
|
||||
|
|
|
@ -591,6 +591,11 @@ abstract class PhabricatorApplicationTransactionEditor
|
|||
// need it to be up to date once the next page loads, but if we don't go
|
||||
// there we we could move it into search once search moves to the daemons.
|
||||
|
||||
// It now happens in the search indexer as well, but the search indexer is
|
||||
// always daemonized, so the logic above still potentially holds. We could
|
||||
// possibly get rid of this. The major motivation for putting it in the
|
||||
// indexer was to enable reindexing to work.
|
||||
|
||||
$fields = PhabricatorCustomField::getObjectFields(
|
||||
$object,
|
||||
PhabricatorCustomField::ROLE_APPLICATIONSEARCH);
|
||||
|
|
Loading…
Reference in a new issue