diff --git a/scripts/search/reindex_everything.php b/scripts/search/reindex_everything.php index 0e4eea2c03..8081c58338 100755 --- a/scripts/search/reindex_everything.php +++ b/scripts/search/reindex_everything.php @@ -1,56 +1,50 @@ #!/usr/bin/env php loadAll(); -$count = count($revs); -echo "Reindexing {$count} revisions"; +echo "Reindexing revisions...\n"; +$revs = new LiskMigrationIterator(new DifferentialRevision()); foreach ($revs as $rev) { PhabricatorSearchDifferentialIndexer::indexRevision($rev); echo '.'; } echo "\n"; -echo "Loading commits...\n"; -$commits = id(new PhabricatorRepositoryCommit())->loadAll(); -$count = count($commits); -echo "Reindexing {$count} commits"; +echo "Reindexing commits...\n"; +$commits = new LiskMigrationIterator(new PhabricatorRepositoryCommit()); foreach ($commits as $commit) { PhabricatorSearchCommitIndexer::indexCommit($commit); echo '.'; } echo "\n"; -echo "Loading tasks...\n"; -$tasks = id(new ManiphestTask())->loadAll(); -$count = count($tasks); -echo "Reindexing {$count} tasks"; +echo "Reindexing tasks...\n"; +$tasks = new LiskMigrationIterator(new ManiphestTask()); foreach ($tasks as $task) { PhabricatorSearchManiphestIndexer::indexTask($task); echo '.'; } echo "\n"; -echo "Done.\n"; +include dirname(__FILE__).'/reindex_all_users.php'; diff --git a/src/applications/search/index/indexer/PhabricatorSearchDifferentialIndexer.php b/src/applications/search/index/indexer/PhabricatorSearchDifferentialIndexer.php index 1e3f6f878a..b621acbe21 100644 --- a/src/applications/search/index/indexer/PhabricatorSearchDifferentialIndexer.php +++ b/src/applications/search/index/indexer/PhabricatorSearchDifferentialIndexer.php @@ -1,118 +1,118 @@ setPHID($rev->getPHID()); $doc->setDocumentType(PhabricatorPHIDConstants::PHID_TYPE_DREV); $doc->setDocumentTitle($rev->getTitle()); $doc->setDocumentCreated($rev->getDateCreated()); $doc->setDocumentModified($rev->getDateModified()); $doc->addField( PhabricatorSearchField::FIELD_BODY, $rev->getSummary()); $doc->addField( PhabricatorSearchField::FIELD_TEST_PLAN, $rev->getTestPlan()); $doc->addRelationship( PhabricatorSearchRelationship::RELATIONSHIP_AUTHOR, $rev->getAuthorPHID(), PhabricatorPHIDConstants::PHID_TYPE_USER, $rev->getDateCreated()); if ($rev->getStatus() != ArcanistDifferentialRevisionStatus::CLOSED && $rev->getStatus() != ArcanistDifferentialRevisionStatus::ABANDONED) { $doc->addRelationship( PhabricatorSearchRelationship::RELATIONSHIP_OPEN, $rev->getPHID(), PhabricatorPHIDConstants::PHID_TYPE_DREV, time()); } - $comments = id(new DifferentialComment())->loadAllWhere( - 'revisionID = %d', - $rev->getID()); + $comments = $rev->loadRelatives(new DifferentialComment(), 'revisionID'); - $inlines = id(new DifferentialInlineComment())->loadAllWhere( - 'revisionID = %d AND commentID IS NOT NULL', - $rev->getID()); + $inlines = $rev->loadRelatives( + new DifferentialInlineComment(), + 'revisionID', + 'getID', + '(commentID IS NOT NULL)'); $touches = array(); foreach (array_merge($comments, $inlines) as $comment) { if (strlen($comment->getContent())) { $doc->addField( PhabricatorSearchField::FIELD_COMMENT, $comment->getContent()); } $author = $comment->getAuthorPHID(); $touches[$author] = $comment->getDateCreated(); } foreach ($touches as $touch => $time) { $doc->addRelationship( PhabricatorSearchRelationship::RELATIONSHIP_TOUCH, $touch, PhabricatorPHIDConstants::PHID_TYPE_USER, $time); } $rev->loadRelationships(); // If a revision needs review, the owners are the reviewers. Otherwise, the // owner is the author (e.g., accepted, rejected, closed). if ($rev->getStatus() == ArcanistDifferentialRevisionStatus::NEEDS_REVIEW) { foreach ($rev->getReviewers() as $phid) { $doc->addRelationship( PhabricatorSearchRelationship::RELATIONSHIP_OWNER, $phid, PhabricatorPHIDConstants::PHID_TYPE_USER, $rev->getDateModified()); // Bogus timestamp. } } else { $doc->addRelationship( PhabricatorSearchRelationship::RELATIONSHIP_OWNER, $rev->getAuthorPHID(), PhabricatorPHIDConstants::PHID_TYPE_USER, $rev->getDateCreated()); } $ccphids = $rev->getCCPHIDs(); $handles = id(new PhabricatorObjectHandleData($ccphids)) ->loadHandles(); foreach ($handles as $phid => $handle) { $doc->addRelationship( PhabricatorSearchRelationship::RELATIONSHIP_SUBSCRIBER, $phid, $handle->getType(), $rev->getDateModified()); // Bogus timestamp. } self::reindexAbstractDocument($doc); } } diff --git a/src/infrastructure/storage/lisk/LiskMigrationIterator.php b/src/infrastructure/storage/lisk/LiskMigrationIterator.php index 1a8b46aa9b..cb3eaaa45c 100644 --- a/src/infrastructure/storage/lisk/LiskMigrationIterator.php +++ b/src/infrastructure/storage/lisk/LiskMigrationIterator.php @@ -1,60 +1,64 @@ object = $object; + $this->set = new LiskDAOSet(); + $this->object = $object->putInSet($this->set); } protected function didRewind() { $this->cursor = 0; } public function key() { return $this->current()->getID(); } protected function loadPage() { + $this->set->clearSet(); + $results = $this->object->loadAllWhere( 'id > %d ORDER BY id ASC LIMIT %d', $this->cursor, $this->getPageSize()); if ($results) { $this->cursor = last($results)->getID(); } return $results; } }