/** * @param ConsoleTerminateEvent $event */ public function onConsoleTerminate(ConsoleTerminateEvent $event) { if ($this->isProcessingRequired($event)) { if ($event->getExitCode() === 0) { $this->searchEngine->reindex(); } $this->searchListener->setEnabled(true); } }
/** * Run query with query builder * * @param Query $query * @return Result */ public function query(Query $query) { $this->prepareQuery($query); // we haven't allowed entities, so return null search result if (count($query->getFrom()) == 0) { return new Result($query, [], 0); } return $this->engine->search($query); }
/** * Synchronise all changed entities with search index */ protected function indexEntities() { // process saved entities if ($this->savedEntities) { $savedEntities = $this->savedEntities; $this->savedEntities = []; $this->searchEngine->save($savedEntities, $this->realTimeUpdate); } // process deleted entities if ($this->deletedEntities) { $deletedEntities = $this->deletedEntities; $this->deletedEntities = []; $this->searchEngine->delete($deletedEntities, $this->realTimeUpdate); } }