Skip to content

Commit

Permalink
fix: service configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
sitepark-veltrup committed Mar 22, 2024
1 parent 795241f commit be69fb5
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 13 deletions.
20 changes: 12 additions & 8 deletions config/commands.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,14 @@ services:
atoolo.search.indexer.progressBar:
class: 'Atoolo\Search\Console\Command\Io\IndexerProgressBar'

atoolo.search.indexer.resourceFilter:
class: Atoolo\Search\Service\Indexer\SiteKit\NoIndexFilter

atoolo.search.indexer.internalResourceIndexer:
class: Atoolo\Search\Service\Indexer\InternalResourceIndexer
arguments:
- !tagged_iterator atoolo.search.indexer.documentEnricher.schema2x
- '@atoolo.search.indexer.resourceFilter'
- '@atoolo.search.indexer.progressBar'
- '@atoolo.search.indexer.locationFinder'
- '@atoolo.resource.resourceLoader'
Expand All @@ -33,21 +37,21 @@ services:
- '@atoolo.search.indexer.aborter'
- 'internal'

atoolo.search.selectSearcher:
class: Atoolo\Search\Service\Search\SolrSelect
atoolo.search.search:
class: Atoolo\Search\Service\Search\SolrSearch
arguments:
- '@atoolo.search.indexName'
- '@atoolo.search.solariumClientFactory'
- !tagged_iterator atoolo.search.queryModifier
- '@atoolo.search.resultToResourceResolver'
- !tagged_iterator atoolo.search.queryModifier

atoolo.search.suggestSearcher:
atoolo.search.suggest:
class: Atoolo\Search\Service\Search\SolrSuggest
arguments:
- '@atoolo.search.indexName'
- '@atoolo.search.solariumClientFactory'

atoolo.search.moreLikeThisSearcher:
atoolo.search.moreLikeThis:
class: Atoolo\Search\Service\Search\SolrMoreLikeThis
arguments:
- '@atoolo.search.indexName'
Expand All @@ -61,15 +65,15 @@ services:

Atoolo\Search\Console\Command\Search:
arguments:
- '@atoolo.search.selectSearcher'
- '@atoolo.search.search'

Atoolo\Search\Console\Command\Suggest:
arguments:
- '@atoolo.search.suggestSearcher'
- '@atoolo.search.suggest'

Atoolo\Search\Console\Command\MoreLikeThis:
arguments:
- '@atoolo.search.moreLikeThisSearcher'
- '@atoolo.search.moreLikeThis'


Atoolo\Search\Console\Application:
Expand Down
4 changes: 4 additions & 0 deletions src/Console/Command/MoreLikeThis.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ protected function buildQuery(

protected function outputResult(SearchResult $result): void
{
if ($result->total === 0) {
$this->io->text('No results found.');
return;
}
$this->io->text($result->total . " Results:");
foreach ($result as $resource) {
$this->io->text($resource->getLocation());
Expand Down
6 changes: 6 additions & 0 deletions src/Console/Command/Search.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,12 @@ protected function buildQuery(InputInterface $input): SearchQuery
protected function outputResult(
SearchResult $result
): void {

if ($result->total === 0) {
$this->io->text('No results found');
return;
}

$this->io->title('Results (' . $result->total . ')');
foreach ($result as $resource) {
$this->io->text($resource->getLocation());
Expand Down
5 changes: 5 additions & 0 deletions src/Console/Command/Suggest.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@ protected function buildQuery(string $terms, string $lang): SuggestQuery

protected function outputResult(SuggestResult $result): void
{
if (empty($result->suggestions)) {
$this->io->text('No suggestions found');
return;
}

foreach ($result as $suggest) {
$this->io->text(
$suggest->term .
Expand Down
14 changes: 10 additions & 4 deletions src/Service/Indexer/BackgroundIndexerProgressState.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use Atoolo\Search\Dto\Indexer\IndexerStatus;
use Atoolo\Search\Dto\Indexer\IndexerStatusState;
use Atoolo\Search\Service\IndexName;
use DateTime;
use JsonException;
use Psr\Log\LoggerInterface;
Expand All @@ -20,7 +21,7 @@ class BackgroundIndexerProgressState implements IndexerProgressHandler
private bool $isUpdate = false;

public function __construct(
private string $index,
private readonly IndexName $index,
private readonly IndexerStatusStore $statusStore,
private readonly LoggerInterface $logger = new NullLogger()
) {
Expand All @@ -47,7 +48,7 @@ public function start(int $total): void
public function startUpdate(int $total): void
{
$this->isUpdate = true;
$storedStatus = $this->statusStore->load($this->index);
$storedStatus = $this->statusStore->load($this->getIndex());
$this->status = new IndexerStatus(
IndexerStatusState::RUNNING,
$storedStatus->startTime,
Expand All @@ -71,7 +72,7 @@ public function advance(int $step): void
if ($this->isUpdate) {
$this->status->updated += $step;
}
$this->statusStore->store($this->index, $this->status);
$this->statusStore->store($this->getIndex(), $this->status);
}


Expand Down Expand Up @@ -102,7 +103,7 @@ public function finish(): void
if ($this->status->state === IndexerStatusState::RUNNING) {
$this->status->state = IndexerStatusState::FINISHED;
}
$this->statusStore->store($this->index, $this->status);
$this->statusStore->store($this->getIndex(), $this->status);
}

public function abort(): void
Expand All @@ -114,4 +115,9 @@ public function getStatus(): IndexerStatus
{
return $this->status;
}

private function getIndex(): string
{
return $this->index->name('');
}
}
2 changes: 1 addition & 1 deletion src/Service/Search/SolrMoreLikeThis.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ private function buildResult(
->loadResourceList($result, $lang);

return new SearchResult(
$result->getNumFound() ?? -1,
$result->getNumFound() ?? 0,
0,
0,
$resourceList,
Expand Down

0 comments on commit be69fb5

Please sign in to comment.