diff --git a/src/Builder/ClientBuilder.php b/src/Builder/ClientBuilder.php index b70bc48..87c543d 100644 --- a/src/Builder/ClientBuilder.php +++ b/src/Builder/ClientBuilder.php @@ -1,5 +1,16 @@ writeln('no context definition name given'); + return Command::FAILURE; } @@ -52,6 +64,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $this->indexManager->rebuildIndex($contextName); } catch (\Throwable $e) { $output->writeln(sprintf('Error rebuilding index mapping: %s', $e->getMessage())); + return Command::FAILURE; } diff --git a/src/Controller/Admin/IndexController.php b/src/Controller/Admin/IndexController.php index f22b4c8..e96b327 100644 --- a/src/Controller/Admin/IndexController.php +++ b/src/Controller/Admin/IndexController.php @@ -1,5 +1,16 @@ getMessage(), PreConfiguredIndexProviderInterface::class + $e->getMessage(), + PreConfiguredIndexProviderInterface::class ) ); } @@ -59,6 +69,4 @@ public function rebuildIndex(string $contextName): void $indexService->createIndex($indexDocument); } - - } diff --git a/src/Normalizer/DocumentRawNormalizer.php b/src/Normalizer/DocumentRawNormalizer.php index e6d53ed..1bce39e 100644 --- a/src/Normalizer/DocumentRawNormalizer.php +++ b/src/Normalizer/DocumentRawNormalizer.php @@ -1,5 +1,16 @@ hasParameter('fullDatabaseResponse') === false) { $message = sprintf('Parameter "fullDatabaseResponse" is required to normalize raw result but is missing'); + throw new NormalizerException($message, __CLASS__); } diff --git a/src/Normalizer/DocumentSourceNormalizer.php b/src/Normalizer/DocumentSourceNormalizer.php index 956c23d..b51cec2 100644 --- a/src/Normalizer/DocumentSourceNormalizer.php +++ b/src/Normalizer/DocumentSourceNormalizer.php @@ -1,5 +1,16 @@ getParameter('fullDatabaseResponse'); $viewVars = [ - 'name' => $this->name, + 'name' => $this->name, 'template' => [sprintf('%s/%s.html.twig', self::VIEW_TEMPLATE_PATH, $this->name), sprintf('%s/aggregation.html.twig', self::VIEW_TEMPLATE_PATH)], 'label' => $this->options['label'], 'multiple' => $this->options['multiple'], @@ -122,7 +133,6 @@ protected function addQueryFilter(Search $query, array $queryFields): void } foreach ($queryFields as $key => $value) { - if ($key !== $this->name) { continue; } @@ -162,7 +172,6 @@ protected function buildResultArray(array $buckets): array $values = []; foreach ($buckets as $bucket) { - $relationLabel = null; if ($this->options['relation_label'] !== null) { $relationLabel = call_user_func($this->options['relation_label'], $bucket['key'], $queryFields['locale'] ?? null); diff --git a/src/OutputChannel/Filter/CompositeAggregationFilter.php b/src/OutputChannel/Filter/CompositeAggregationFilter.php index 6fa0982..040c3e5 100644 --- a/src/OutputChannel/Filter/CompositeAggregationFilter.php +++ b/src/OutputChannel/Filter/CompositeAggregationFilter.php @@ -1,5 +1,16 @@ $value) { - if ($key !== $this->name) { continue; } @@ -93,7 +103,6 @@ protected function addQueryFilter(Search $query, array $queryFields): void $query->addQuery($boolQuery); } } - } protected function buildResultArray(array $buckets): array @@ -106,7 +115,6 @@ protected function buildResultArray(array $buckets): array $values = []; foreach ($buckets as $bucket) { - $bucketValue = rtrim(implode($this->options['separator'], array_values($bucket['key'])), $this->options['separator']); $relationLabel = null; diff --git a/src/OutputChannel/Filter/GeoDistanceFilter.php b/src/OutputChannel/Filter/GeoDistanceFilter.php index b3f6a44..d6f9d50 100644 --- a/src/OutputChannel/Filter/GeoDistanceFilter.php +++ b/src/OutputChannel/Filter/GeoDistanceFilter.php @@ -1,5 +1,16 @@ name), sprintf('%s/geo_distance.html.twig', self::VIEW_TEMPLATE_PATH) ], - 'form_name' => $this->options['field'], + 'form_name' => $this->options['field'], 'distance_form_name' => sprintf('%s_distance', $this->options['field']), - 'distance_unit' => $this->options['distance_unit'], - 'distance_range' => $this->options['distance_range'] + 'distance_unit' => $this->options['distance_unit'], + 'distance_range' => $this->options['distance_range'] ]; } diff --git a/src/OutputChannel/Filter/RangeAggregationFilter.php b/src/OutputChannel/Filter/RangeAggregationFilter.php index f50722a..7784e02 100644 --- a/src/OutputChannel/Filter/RangeAggregationFilter.php +++ b/src/OutputChannel/Filter/RangeAggregationFilter.php @@ -1,5 +1,16 @@ getParameter('fullDatabaseResponse'); $viewVars = [ - 'name' => $this->name, + 'name' => $this->name, 'template' => [sprintf('%s/%s.html.twig', self::VIEW_TEMPLATE_PATH, $this->name), sprintf('%s/aggregation.html.twig', self::VIEW_TEMPLATE_PATH)], 'label' => $this->options['label'], 'multiple' => $this->options['multiple'], diff --git a/src/OutputChannel/Modifier/Filter/QueryCleanTermFilter.php b/src/OutputChannel/Modifier/Filter/QueryCleanTermFilter.php index 74524d7..e447309 100644 --- a/src/OutputChannel/Modifier/Filter/QueryCleanTermFilter.php +++ b/src/OutputChannel/Modifier/Filter/QueryCleanTermFilter.php @@ -1,5 +1,16 @@ function (OptionsResolver $spoolResolver) { - $spoolResolver->setDefaults([ 'identifier' => null, 'force_adding_document' => true, 'hosts' => null, 'settings' => null, 'credentials' => function (OptionsResolver $spoolResolver) { - $spoolResolver->setDefaults([ 'username' => null, 'password' => null, @@ -53,7 +62,6 @@ public static function configureOptions(OptionsResolver $resolver): void $spoolResolver->setAllowedTypes('credentials', ['array']); }, 'analysis' => function (OptionsResolver $spoolResolver) { - $spoolResolver->setDefaults([ 'filter' => [], 'char_filter' => [], @@ -162,8 +170,10 @@ public function processDocument(ContextDefinitionInterface $contextDefinition, I break; default: - throw new \Exception(sprintf('invalid context dispatch type "%s". cannot perform index provider dispatch.', - $contextDefinition->getContextDispatchType())); + throw new \Exception(sprintf( + 'invalid context dispatch type "%s". cannot perform index provider dispatch.', + $contextDefinition->getContextDispatchType() + )); } } catch (\Throwable $e) { throw new ProviderException($e->getMessage(), DsOpenSearchBundle::PROVIDER_NAME, $e); diff --git a/src/Service/IndexPersistenceService.php b/src/Service/IndexPersistenceService.php index 2d18ea5..51e682f 100644 --- a/src/Service/IndexPersistenceService.php +++ b/src/Service/IndexPersistenceService.php @@ -1,5 +1,16 @@ client->indices()->flush(); + break; case 'refresh': $this->client->indices()->refresh(); + break; } @@ -239,7 +252,6 @@ protected function getIndexDocumentFields(IndexDocument $document): array { $fields = []; foreach ($document->getIndexFields() as $field) { - $data = $field->getData(); if (!is_array($data)) { @@ -261,10 +273,10 @@ protected function parseMappings(IndexDocument $indexDocument): ?array $hasDynamicFields = false; foreach ($indexDocument->getIndexFields() as $indexField) { - // fields should be dynamic, do not create mapping if ($indexField->getIndexType() === 'dynamic') { $hasDynamicFields = true; + continue; } diff --git a/src/Service/IndexQueryService.php b/src/Service/IndexQueryService.php index 8ad2373..70e40f5 100644 --- a/src/Service/IndexQueryService.php +++ b/src/Service/IndexQueryService.php @@ -1,5 +1,16 @@ indexOptions['index']['identifier']; } - }