Changeset View
Changeset View
Standalone View
Standalone View
src/infrastructure/cluster/search/PhabricatorSearchService.php
| Show First 20 Lines • Show All 229 Lines • ▼ Show 20 Lines | class PhabricatorSearchService | ||||
| } | } | ||||
| /** | /** | ||||
| * Execute a full-text query and return a list of PHIDs of matching objects. | * Execute a full-text query and return a list of PHIDs of matching objects. | ||||
| * @return string[] | * @return string[] | ||||
| * @throws PhutilAggregateException | * @throws PhutilAggregateException | ||||
| */ | */ | ||||
| public static function executeSearch(PhabricatorSavedQuery $query) { | public static function executeSearch(PhabricatorSavedQuery $query) { | ||||
| $services = self::getAllServices(); | |||||
| $exceptions = array(); | $exceptions = array(); | ||||
| foreach ($services as $service) { | // try all services until one succeeds | ||||
| $engine = $service->getEngine(); | foreach (self::getAllServices() as $service) { | ||||
| // try all hosts until one succeeds | |||||
| try { | try { | ||||
| $engine = $service->getEngine(); | |||||
| $res = $engine->executeSearch($query); | $res = $engine->executeSearch($query); | ||||
| // return immediately if we get results without an exception | // return immediately if we get results | ||||
| return $res; | return $res; | ||||
| } catch (Exception $ex) { | } catch (Exception $ex) { | ||||
| $exceptions[] = $ex; | $exceptions[] = $ex; | ||||
| } | } | ||||
| } | } | ||||
| throw new PhutilAggregateException('All search engines failed:', | $msg = pht('All of the configured Fulltext Search services failed.'); | ||||
| $exceptions); | throw new PhutilAggregateException($msg, $exceptions); | ||||
| } | } | ||||
| } | } | ||||