Differential D10955 Diff 26411 src/applications/search/management/PhabricatorSearchManagementInitWorkflow.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/search/management/PhabricatorSearchManagementInitWorkflow.php
- This file was added.
<?php | |||||
final class PhabricatorSearchManagementInitWorkflow | |||||
extends PhabricatorSearchManagementWorkflow { | |||||
protected function didConstruct() { | |||||
$this | |||||
->setName('init') | |||||
->setSynopsis('Initialize or repair an index.') | |||||
->setExamples('**init**'); | |||||
} | |||||
public function execute(PhutilArgumentParser $args) { | |||||
$console = PhutilConsole::getConsole(); | |||||
$engine = PhabricatorSearchEngineSelector::newSelector()->newEngine(); | |||||
$work_done = false; | |||||
if (!$engine->indexExists()) { | |||||
$console->writeOut( | |||||
'%s', | |||||
pht('Index does not exist, creating...')); | |||||
epriestley: You could safely remove this and we'll just no-op MySQL and have a more general implementation… | |||||
Not Done Inline ActionsI wasn't sure if you wanted the stubs in the base class which is why I went this way. Can totally go that route though. WikiChad: I wasn't sure if you wanted the stubs in the base class which is why I went this way. Can… | |||||
$engine->initIndex(); | |||||
$console->writeOut( | |||||
"%s\n", | |||||
pht('done.')); | |||||
$work_done = true; | |||||
} else if (!$engine->indexIsSane()) { | |||||
$console->writeOut( | |||||
'%s', | |||||
pht('Index exists but is incorrect, fixing...')); | |||||
$engine->initIndex(); | |||||
$console->writeOut( | |||||
"%s\n", | |||||
pht('done.')); | |||||
$work_done = true; | |||||
} | |||||
if ($work_done) { | |||||
$console->writeOut( | |||||
"%s\n", | |||||
pht('Index maintenance complete. Run `./bin/search index` to '. | |||||
'reindex documents')); | |||||
} else { | |||||
$console->writeOut( | |||||
"%s\n", | |||||
pht('Nothing to do.')); | |||||
} | |||||
} | |||||
} |
You could safely remove this and we'll just no-op MySQL and have a more general implementation, right?
I think putting a couple of extra stubs in the base class is cleaner than having an ElasticSearch-specific chunk of code here, since it seems pretty reasonable that we may eventually support, e.g., Solr or AWS CloudSearch (although neither are on the horizon).