Skip to content

Commit

Permalink
[Pipeline] #1245170 - Prevent empty pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
PierreGauthier committed Sep 19, 2024
1 parent 092cc71 commit 62ea5f7
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
6 changes: 4 additions & 2 deletions src/Index/Service/IndexSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -433,9 +433,11 @@ public function getDynamicIndexSettings(Metadata $metadata, LocalizedCatalog|int
$complexeSourceField = $this->sourceFieldRepository->getComplexeFields($metadata);
$settings += ['mapping.nested_fields.limit' => \count($complexeSourceField)];

// Add default pipeline
// Add default pipeline if any processor are defined.
$pipeline = $this->pipelineRepository->createByMetadata($metadata);
$settings['default_pipeline'] = $pipeline->getName();
if ($pipeline) {
$settings['default_pipeline'] = $pipeline->getName();
}

return $settings;
}
Expand Down
6 changes: 4 additions & 2 deletions src/Search/Repository/Ingest/PipelineRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function get(string $name): ?IngestPipeline
/**
* @throws \Exception
*/
public function createByMetadata(Metadata $metadata): IngestPipeline
public function createByMetadata(Metadata $metadata): ?IngestPipeline
{
$pipelineName = $this->pipelinePrefix . $metadata->getEntity();
$processors = [];
Expand All @@ -72,6 +72,8 @@ public function createByMetadata(Metadata $metadata): IngestPipeline
$processors = array_merge($processors, $processorsProvider->getProcessors($metadata));
}

return $this->create($pipelineName, $pipelineName, $processors);
return empty($processors)
? null
: $this->create($pipelineName, $pipelineName, $processors);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,5 @@ public function get(string $name): ?IngestPipeline;
*
* @param Metadata $metadata metadata
*/
public function createByMetadata(Metadata $metadata): IngestPipeline;
public function createByMetadata(Metadata $metadata): ?IngestPipeline;
}

0 comments on commit 62ea5f7

Please sign in to comment.