mirror of
https://we.phorge.it/source/phorge.git
synced 2025-02-26 13:39:08 +01:00
Summary: Ref T3165. Builds a dedicated index for Conpherence to avoid scale/policy filtering concerns. - This is pretty one-off but I think it's generally OK. - There's no UI for it. - `ConpherenceFulltextQuery` is very low-level. You would need to do another query on the PHIDs it returns to actually show anything to the user. - The `previousTransactionPHID` is so you can load chat context efficiently. Specifically, if you want to show results like this: > previous line of context > **line of chat that matches the query** > next line of context ...you can read the previous lines out of `previousTransactionPHID` directly, and the next lines by issuing one query with `WHERE previousTransactionPHID IN (...)`. I'm not 100% sure this is useful, but it seemed like a reasonable thing to provide, since there's no way to query this efficiently otherwise and I figure a lot of chat might make way more sense with a couple of lines of context. Test Plan: - Indexed a thread manually (whole thing indexed). - Indexed a thread by updating it (just the new comment indexed). - Wrote a hacky test script and got reasonable-looking query results. Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T3165 Differential Revision: https://secure.phabricator.com/D11234
32 lines
750 B
PHP
32 lines
750 B
PHP
<?php
|
|
|
|
final class PhabricatorSearchIndexer {
|
|
|
|
public function queueDocumentForIndexing($phid, $context = null) {
|
|
PhabricatorWorker::scheduleTask(
|
|
'PhabricatorSearchWorker',
|
|
array(
|
|
'documentPHID' => $phid,
|
|
'context' => $context,
|
|
),
|
|
array(
|
|
'priority' => PhabricatorWorker::PRIORITY_IMPORT,
|
|
));
|
|
}
|
|
|
|
public function indexDocumentByPHID($phid, $context) {
|
|
$indexers = id(new PhutilSymbolLoader())
|
|
->setAncestorClass('PhabricatorSearchDocumentIndexer')
|
|
->loadObjects();
|
|
|
|
foreach ($indexers as $indexer) {
|
|
if ($indexer->shouldIndexDocumentByPHID($phid)) {
|
|
$indexer->indexDocumentByPHID($phid, $context);
|
|
break;
|
|
}
|
|
}
|
|
|
|
return $this;
|
|
}
|
|
|
|
}
|