diff --git a/doc/05_Index_Service/01_Product_Index_Configuration/07_Elastic_Search/README.md b/doc/05_Index_Service/01_Product_Index_Configuration/07_Elastic_Search/README.md
index 78216d77..8b391952 100644
--- a/doc/05_Index_Service/01_Product_Index_Configuration/07_Elastic_Search/README.md
+++ b/doc/05_Index_Service/01_Product_Index_Configuration/07_Elastic_Search/README.md
@@ -27,7 +27,7 @@ To manually start a reindex, following command can be used: `bin/console ecommer
:::caution
-The existing command `bin/console ecommerce:indexservice:search-elasticsearch-sync reindex` is deprecated and will be removed in 2.0.0.
+The command `bin/console ecommerce:indexservice:search-elasticsearch-sync reindex` was removed in 2.0.0.
:::
diff --git a/doc/19_Upgrade_Notes/README.md b/doc/19_Upgrade_Notes/README.md
new file mode 100644
index 00000000..d580c80c
--- /dev/null
+++ b/doc/19_Upgrade_Notes/README.md
@@ -0,0 +1,10 @@
+# Upgrade Notes
+
+## Version 2.0.0
+
+### [Elasticsearch]
+
+- Removed ElasticSearchConfigInterface, use SearchConfigInterface instead.
+- Removed EsSyncCommand it is now IndexSyncCommand. Use the ecommerce:indexservice:search-index-sync command instead.
+- Introduced IndexRefreshInterface for refresh command.
+- Moved ElasticSearch Filter Types to SearchIndex namespace. Make sure to update your filter namespaces in your yaml configuration.
\ No newline at end of file
diff --git a/src/Command/IndexService/EsSyncCommand.php b/src/Command/IndexService/EsSyncCommand.php
deleted file mode 100644
index 8b965c35..00000000
--- a/src/Command/IndexService/EsSyncCommand.php
+++ /dev/null
@@ -1,100 +0,0 @@
-getName()
- );
-
- $this
- ->setName('ecommerce:indexservice:elasticsearch-sync')
- ->setDescription(
- 'Refresh elastic search (ES) index settings, mappings via native ES-API. (Deprecated)'
- )
- ->addArgument('mode', InputArgument::REQUIRED,
- 'reindex: Reindexes ES indices based on the their native reindexing API. Might be necessary when mapping has changed.'.PHP_EOL.
- 'update-synonyms: Activate changes in synonym files, by closing and reopening the ES index.'
- )
- ->addOption('tenant', null, InputOption::VALUE_OPTIONAL,
- 'If a tenant name is provided (e.g. assortment_de), then only that specific tenant will be synced. '.
- 'Otherwise all tenants will be synced.'
- )
- ;
- }
-
- protected function execute(InputInterface $input, OutputInterface $output): int
- {
- $mode = $input->getArgument('mode');
- $tenantName = $input->getOption('tenant');
-
- $indexService = Factory::getInstance()->getIndexService();
- $tenantList = $tenantName ? [$tenantName] : $indexService->getTenants();
-
- if (!in_array($mode, ['reindex', 'update-synonyms'])) {
- $output->writeln("Unknown mode \"{$mode}\")...");
- exit(1);
- }
-
- $bar = new ProgressBar($output, count($tenantList));
-
- foreach ($tenantList as $tenantName) {
- $elasticWorker = $indexService->getTenantWorker($tenantName); //e.g., 'AT_de_elastic'
-
- if (!$elasticWorker instanceof AbstractElasticSearch) {
- $output->writeln("Skipping tenant \"{$tenantName}\" as it's not an elasticsearch tenant.");
-
- continue;
- }
-
- $output->writeln("Process tenant \"{$tenantName}\" (mode \"{$mode}\")...");
-
- if ('reindex' == $mode) {
- $elasticWorker->startReindexMode();
- } elseif ('update-synonyms' == $mode) {
- $elasticWorker->updateSynonyms();
- }
-
- $bar->advance(1);
- }
-
- $bar->finish();
-
- return 0;
- }
-}
diff --git a/src/Command/IndexService/IndexSyncCommand.php b/src/Command/IndexService/IndexSyncCommand.php
index 57b4c555..254c7c01 100644
--- a/src/Command/IndexService/IndexSyncCommand.php
+++ b/src/Command/IndexService/IndexSyncCommand.php
@@ -18,8 +18,7 @@
use Exception;
use Pimcore\Bundle\EcommerceFrameworkBundle\Factory;
-use Pimcore\Bundle\EcommerceFrameworkBundle\IndexService\Worker\ElasticSearch\AbstractElasticSearch;
-use Pimcore\Bundle\EcommerceFrameworkBundle\IndexService\Worker\OpenSearch\AbstractOpenSearch;
+use Pimcore\Bundle\EcommerceFrameworkBundle\IndexService\Worker\IndexRefreshInterface;
use Symfony\Component\Console\Helper\ProgressBar;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
@@ -66,9 +65,9 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$bar = new ProgressBar($output, count($tenantList));
foreach ($tenantList as $tenantName) {
- $elasticWorker = $indexService->getTenantWorker($tenantName); //e.g., 'AT_de_elastic'
+ $tenantWorker = $indexService->getTenantWorker($tenantName); //e.g., 'AT_de_elastic'
- if (!$elasticWorker instanceof AbstractElasticSearch && !$elasticWorker instanceof AbstractOpenSearch) {
+ if (!$tenantWorker instanceof IndexRefreshInterface) {
$output->writeln("Skipping tenant \"{$tenantName}\" as it's not a valid search index tenant.");
continue;
@@ -78,8 +77,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int
try {
match ($mode) {
- 'reindex' => $elasticWorker->startReindexMode(),
- 'update-synonyms' => $elasticWorker->updateSynonyms(),
+ 'reindex' => $tenantWorker->startReindexMode(),
+ 'update-synonyms' => $tenantWorker->updateSynonyms(),
default => null,
};
} catch (Exception $e) {
diff --git a/src/FilterService/FilterType/ElasticSearch/Input.php b/src/FilterService/FilterType/ElasticSearch/Input.php
deleted file mode 100644
index 754facc8..00000000
--- a/src/FilterService/FilterType/ElasticSearch/Input.php
+++ /dev/null
@@ -1,61 +0,0 @@
-getField($filterDefinition);
-
- if (!$filterDefinition instanceof FilterInputfield) {
- throw new InvalidConfigException('invalid config');
- }
- $preSelect = $filterDefinition->getPreSelect();
-
- $value = $params[$field] ?? null;
- $isReload = $params['is_reload'] ?? null;
-
- if ($value == AbstractFilterType::EMPTY_STRING) {
- $value = null;
- } elseif (empty($value) && !$isReload) {
- $value = $preSelect;
- }
-
- if (is_string($value)) {
- $value = trim($value);
- }
-
- $currentFilter[$field] = $value;
-
- if (!empty($value)) {
- $value = '.*"' . $value . '".*';
- $productList->addCondition(['regexp' => ['attributes.' . $field => $value]], $field);
- }
-
- return $currentFilter;
- }
-}
diff --git a/src/FilterService/FilterType/ElasticSearch/MultiSelect.php b/src/FilterService/FilterType/ElasticSearch/MultiSelect.php
deleted file mode 100644
index 6647b6bf..00000000
--- a/src/FilterService/FilterType/ElasticSearch/MultiSelect.php
+++ /dev/null
@@ -1,102 +0,0 @@
-getField($filterDefinition);
- $productList->prepareGroupByValues($field, true, !$filterDefinition->getUseAndCondition());
- }
-
- /**
- * @param FilterMultiSelect $filterDefinition
- *
- */
- public function addCondition(AbstractFilterDefinitionType $filterDefinition, ProductListInterface $productList, array $currentFilter, array $params, bool $isPrecondition = false): array
- {
- $field = $this->getField($filterDefinition);
- $preSelect = $this->getPreSelect($filterDefinition);
-
- $value = $params[$field] ?? null;
- $isReload = $params['is_reload'] ?? null;
-
- if (!empty($value)) {
- if (!is_array($value)) {
- $value = [$value];
- }
- }
-
- if (empty($value) && !$isReload) {
- if (!empty($preSelect) || $preSelect == '0') {
- $value = explode(',', $preSelect);
- }
- } elseif (!empty($value) && in_array(AbstractFilterType::EMPTY_STRING, $value)) {
- $value = null;
- }
-
- $currentFilter[$field] = $value;
-
- if (!empty($value)) {
- $quotedValues = [];
- foreach ($value as $v) {
- if (!empty($v)) {
- $quotedValues[] = $v;
- }
- }
-
- if (!$productList instanceof AbstractElasticSearch) {
- throw new InvalidConfigException('invalid configuration');
- }
-
- $tenantConfig = $productList->getTenantConfig();
- $attributeConfig = $tenantConfig->getAttributeConfig()[$field];
- if ($attributeConfig['type'] == 'boolean') {
- foreach ($quotedValues as $k => $v) {
- $quotedValues[$k] = (bool)$v;
- }
- }
-
- if (!empty($quotedValues)) {
- if ($filterDefinition->getUseAndCondition()) {
- foreach ($quotedValues as $value) {
- $productList->addCondition($value, $field);
- }
- } else {
- $productList->addCondition(['terms' => ['attributes.' . $field => $quotedValues]], $field);
- }
- }
- }
-
- return $currentFilter;
- }
-}
diff --git a/src/FilterService/FilterType/ElasticSearch/MultiSelectFromMultiSelect.php b/src/FilterService/FilterType/ElasticSearch/MultiSelectFromMultiSelect.php
deleted file mode 100644
index f008f4b0..00000000
--- a/src/FilterService/FilterType/ElasticSearch/MultiSelectFromMultiSelect.php
+++ /dev/null
@@ -1,95 +0,0 @@
-getUseAndCondition();
-
- $field = $this->getField($filterDefinition);
- $productList->prepareGroupByValues($field, true, !$useAndCondition);
- }
-
- /**
- *
- * @return string[]
- */
- public function addCondition(AbstractFilterDefinitionType $filterDefinition, ProductListInterface $productList, array $currentFilter, array $params, bool $isPrecondition = false): array
- {
- $field = $this->getField($filterDefinition);
- $preSelect = $this->getPreSelect($filterDefinition);
-
- $value = $params[$field] ?? null;
- $isReload = $params['is_reload'] ?? null;
-
- if (empty($value) && !$isReload) {
- if (is_array($preSelect)) {
- $value = $preSelect;
- } else {
- $value = explode(',', $preSelect);
- }
-
- foreach ($value as $key => $v) {
- if (!$v) {
- unset($value[$key]);
- }
- }
- } elseif (!empty($value) && in_array(AbstractFilterType::EMPTY_STRING, $value)) {
- $value = null;
- }
-
- $currentFilter[$field] = $value;
-
- if (!empty($value)) {
- if (!$filterDefinition instanceof FilterMultiSelectFromMultiSelect) {
- throw new InvalidConfigException('invalid configuration');
- }
-
- if ($filterDefinition->getUseAndCondition()) {
- foreach ($value as $entry) {
- $productList->addCondition(['term' => ['attributes.' . $field => $entry]], $field);
- }
- } else {
- $boolArray = [];
- foreach ($value as $entry) {
- $boolArray[] = ['term' => ['attributes.' . $field => $entry]];
- }
-
- $productList->addCondition(['bool' => ['should' => $boolArray, 'minimum_should_match' => 1]], $field);
- }
- }
-
- return $currentFilter;
- }
-}
diff --git a/src/FilterService/FilterType/ElasticSearch/MultiSelectRelation.php b/src/FilterService/FilterType/ElasticSearch/MultiSelectRelation.php
deleted file mode 100644
index 20123a70..00000000
--- a/src/FilterService/FilterType/ElasticSearch/MultiSelectRelation.php
+++ /dev/null
@@ -1,94 +0,0 @@
-getField($filterDefinition);
- $productList->prepareGroupByRelationValues($field, true, !$filterDefinition->getUseAndCondition());
- }
-
- /**
- * @param FilterMultiRelation $filterDefinition
- *
- */
- public function addCondition(AbstractFilterDefinitionType $filterDefinition, ProductListInterface $productList, array $currentFilter, array $params, bool $isPrecondition = false): array
- {
- $field = $this->getField($filterDefinition);
- $preSelect = $this->getPreSelect($filterDefinition);
-
- $value = $params[$field] ?? null;
- $isReload = $params['is_reload'] ?? null;
-
- if (empty($value) && !$isReload) {
- $objects = $preSelect;
- $value = [];
-
- if (!is_array($objects)) {
- $objects = explode(',', $objects);
- }
-
- if (is_array($objects)) {
- foreach ($objects as $o) {
- if (is_object($o)) {
- $value[] = $o->getId();
- } else {
- $value[] = $o;
- }
- }
- }
- } elseif (!empty($value) && in_array(AbstractFilterType::EMPTY_STRING, $value)) {
- $value = null;
- }
-
- $currentFilter[$field] = $value;
-
- if (!empty($value)) {
- $quotedValues = [];
- foreach ($value as $v) {
- if (!empty($v)) {
- $quotedValues[] = $v;
- }
- }
- if (!empty($quotedValues)) {
- if ($filterDefinition->getUseAndCondition()) {
- foreach ($quotedValues as $value) {
- $productList->addRelationCondition($field, $value);
- }
- } else {
- $productList->addRelationCondition($field, ['terms' => ['relations.' . $field => $quotedValues]]);
- }
- }
- }
-
- return $currentFilter;
- }
-}
diff --git a/src/FilterService/FilterType/ElasticSearch/NumberRange.php b/src/FilterService/FilterType/ElasticSearch/NumberRange.php
deleted file mode 100644
index 7dcad08f..00000000
--- a/src/FilterService/FilterType/ElasticSearch/NumberRange.php
+++ /dev/null
@@ -1,62 +0,0 @@
-prepareGroupByValues($this->getField($filterDefinition), true);
- }
-
- /**
- * @param FilterNumberRange $filterDefinition
- *
- */
- public function addCondition(AbstractFilterDefinitionType $filterDefinition, ProductListInterface $productList, array $currentFilter, array $params, bool $isPrecondition = false): array
- {
- $field = $this->getField($filterDefinition);
- $value = $params[$field] ?? null;
-
- if (empty($value)) {
- $value['from'] = $filterDefinition->getPreSelectFrom();
- $value['to'] = $filterDefinition->getPreSelectTo();
- }
-
- $currentFilter[$field] = $value;
-
- if (($value['from'] !== null || $value['to'] !== null) && ($value['from'] !== '' || $value['to'] !== '')) {
- $range = [];
- if (strlen((string)$value['from']) > 0) {
- $range['gte'] = $value['from'];
- }
- if (strlen($value['to']) > 0) {
- $range['lte'] = $value['to'];
- }
- $productList->addCondition(['range' => ['attributes.' . $field => $range]], $field);
- }
-
- return $currentFilter;
- }
-}
diff --git a/src/FilterService/FilterType/ElasticSearch/NumberRangeSelection.php b/src/FilterService/FilterType/ElasticSearch/NumberRangeSelection.php
deleted file mode 100644
index 503895f4..00000000
--- a/src/FilterService/FilterType/ElasticSearch/NumberRangeSelection.php
+++ /dev/null
@@ -1,69 +0,0 @@
-prepareGroupByValues($this->getField($filterDefinition), true);
- }
-
- /**
- * @param FilterNumberRangeSelection $filterDefinition
- *
- */
- public function addCondition(AbstractFilterDefinitionType $filterDefinition, ProductListInterface $productList, array $currentFilter, array $params, bool $isPrecondition = false): array
- {
- $field = $this->getField($filterDefinition);
- $rawValue = $params[$field] ?? null;
-
- if (!empty($rawValue) && $rawValue != AbstractFilterType::EMPTY_STRING) {
- $values = explode('-', $rawValue);
- $value['from'] = trim($values[0]);
- $value['to'] = trim($values[1]);
- } elseif ($rawValue == AbstractFilterType::EMPTY_STRING) {
- $value = null;
- } else {
- $value['from'] = $filterDefinition->getPreSelectFrom();
- $value['to'] = $filterDefinition->getPreSelectTo();
- }
-
- $currentFilter[$field] = $value;
-
- if (!empty($value) && ($value['from'] !== null || $value['to'] !== null)) {
- $range = [];
- if (!empty($value['from'])) {
- $range['gte'] = $value['from'];
- }
- if (!empty($value['to'])) {
- $range['lte'] = $value['to'];
- }
- $productList->addCondition(['range' => ['attributes.' . $field => $range]], $field);
- }
-
- return $currentFilter;
- }
-}
diff --git a/src/FilterService/FilterType/ElasticSearch/Select.php b/src/FilterService/FilterType/ElasticSearch/Select.php
deleted file mode 100644
index aaca55c3..00000000
--- a/src/FilterService/FilterType/ElasticSearch/Select.php
+++ /dev/null
@@ -1,56 +0,0 @@
-prepareGroupByValues($this->getField($filterDefinition), true);
- }
-
- public function addCondition(AbstractFilterDefinitionType $filterDefinition, ProductListInterface $productList, array $currentFilter, array $params, bool $isPrecondition = false): array
- {
- $field = $this->getField($filterDefinition);
- $preSelect = $this->getPreSelect($filterDefinition);
-
- $value = $params[$field] ?? null;
- $isReload = $params['is_reload'] ?? null;
-
- if ($value == AbstractFilterType::EMPTY_STRING) {
- $value = null;
- } elseif (empty($value) && !$isReload) {
- $value = $preSelect;
- }
-
- $value = trim((string)$value);
- $currentFilter[$field] = $value;
-
- if (!empty($value)) {
- $productList->addCondition(trim($value), $field);
- }
-
- return $currentFilter;
- }
-}
diff --git a/src/FilterService/FilterType/ElasticSearch/SelectCategory.php b/src/FilterService/FilterType/ElasticSearch/SelectCategory.php
deleted file mode 100644
index d1628d9b..00000000
--- a/src/FilterService/FilterType/ElasticSearch/SelectCategory.php
+++ /dev/null
@@ -1,85 +0,0 @@
-prepareGroupBySystemValues($filterDefinition->getField(), true);
- }
-
- /**
- * @param FilterCategory $filterDefinition
- *
- * @throws \Exception
- */
- public function getFilterValues(AbstractFilterDefinitionType $filterDefinition, ProductListInterface $productList, array $currentFilter): array
- {
- $rawValues = $productList->getGroupBySystemValues($filterDefinition->getField(), true);
- $values = [];
-
- foreach ($rawValues as $v) {
- $values[$v['value']] = ['value' => $v['value'], 'count' => $v['count']];
- }
-
- return [
- 'hideFilter' => $filterDefinition->getRequiredFilterField() && empty($currentFilter[$filterDefinition->getRequiredFilterField()]),
- 'label' => $filterDefinition->getLabel(),
- 'currentValue' => $currentFilter[$filterDefinition->getField()],
- 'values' => array_values($values),
- 'indexedValues' => $values,
- 'document' => $this->request->get('contentDocument'),
- 'fieldname' => $filterDefinition->getField(),
- 'rootCategory' => method_exists($filterDefinition, 'getRootCategory') ? $filterDefinition->getRootCategory() : null,
- 'resultCount' => $productList->count(),
- ];
- }
-
- public function addCondition(AbstractFilterDefinitionType $filterDefinition, ProductListInterface $productList, array $currentFilter, array $params, bool $isPrecondition = false): array
- {
- $value = $params[$filterDefinition->getField()] ?? null;
- $isReload = $params['is_reload'] ?? null;
-
- if ($value == AbstractFilterType::EMPTY_STRING) {
- $value = null;
- } elseif (empty($value) && !$isReload && method_exists($filterDefinition, 'getPreSelect')) {
- $value = $filterDefinition->getPreSelect();
- if ($value instanceof ElementInterface) {
- $value = (string)$value->getId();
- }
- }
-
- $currentFilter[$filterDefinition->getField()] = $value;
-
- if (!empty($value)) {
- $value = trim($value);
- $productList->addCondition($value, $filterDefinition->getField());
- }
-
- return $currentFilter;
- }
-}
diff --git a/src/FilterService/FilterType/ElasticSearch/SelectClassificationStoreAttributes.php b/src/FilterService/FilterType/ElasticSearch/SelectClassificationStoreAttributes.php
deleted file mode 100644
index 89970616..00000000
--- a/src/FilterService/FilterType/ElasticSearch/SelectClassificationStoreAttributes.php
+++ /dev/null
@@ -1,149 +0,0 @@
-getExcludedKeyIds()) {
- $excludedKeys = explode(',', $filterDefinition->getExcludedKeyIds());
- $excludedKeys = array_map('intval', $excludedKeys);
- }
-
- return $excludedKeys;
- }
-
- protected function sortResult(AbstractFilterDefinitionType $filterDefinition, array $keyCollection): array
- {
- if (!method_exists($filterDefinition, 'getKeyIdPriorityOrder') || empty($filterDefinition->getKeyIdPriorityOrder())) {
- return $keyCollection;
- }
-
- $priorityKeys = explode(',', $filterDefinition->getKeyIdPriorityOrder());
- $priorityKeys = array_map('intval', $priorityKeys);
-
- $sortedCollection = [];
-
- foreach ($priorityKeys as $key) {
- $sortedCollection[$key] = $keyCollection[$key];
- unset($keyCollection[$key]);
- }
-
- return $sortedCollection + $keyCollection;
- }
-
- public function prepareGroupByValues(AbstractFilterDefinitionType $filterDefinition, ProductListInterface $productList): void
- {
- $field = $this->getField($filterDefinition);
- $keysField = $field . '.keys';
- $valuesField = $field . '.values';
-
- $productList->prepareGroupByValues($keysField, false, true);
- $values = $productList->getGroupByValues($keysField, false, false);
-
- $excludedKeys = $this->extractExcludedKeys($filterDefinition);
- foreach ($values as $keyId) {
- if (in_array($keyId, $excludedKeys)) {
- continue;
- }
-
- $subField = $valuesField . '.' . $keyId . '.keyword';
- $productList->prepareGroupByValues($subField, false, true);
- }
- }
-
- public function getFilterValues(AbstractFilterDefinitionType $filterDefinition, ProductListInterface $productList, array $currentFilter): array
- {
- $field = $this->getField($filterDefinition);
- $keysField = $field . '.keys';
-
- $keys = $productList->getGroupByValues($keysField, false, false);
-
- $keyCollection = [];
-
- $excludedKeys = $this->extractExcludedKeys($filterDefinition);
- foreach ($keys as $keyId) {
- if (in_array($keyId, $excludedKeys)) {
- continue;
- }
-
- $valuesField = $field . '.values.' . $keyId . '.keyword';
-
- $keyValues = $productList->getGroupByValues($valuesField, true, true);
- if (!empty($keyValues)) {
- $key = KeyConfig::getById($keyId);
-
- $keyCollection[$keyId] = [
- 'keyConfig' => $key,
- 'values' => $keyValues,
- ];
- }
- }
-
- $keyCollection = $this->sortResult($filterDefinition, $keyCollection);
-
- return [
- 'label' => $filterDefinition->getLabel(),
- 'fieldname' => $field,
- 'currentValue' => $currentFilter[$field] ?? null,
- 'values' => $keyCollection,
- 'metaData' => $filterDefinition->getMetaData(),
- ];
- }
-
- public function addCondition(AbstractFilterDefinitionType $filterDefinition, ProductListInterface $productList, array $currentFilter, array $params, bool $isPrecondition = false): array
- {
- $field = $this->getField($filterDefinition);
- $nestedPath = $field . '.values';
-
- $value = $params[$field] ?? null;
-
- if (is_array($value)) {
- foreach ($value as $keyId => $keyValue) {
- $filterValue = trim($keyValue);
- if ($filterValue == AbstractFilterType::EMPTY_STRING) {
- $filterValue = null;
- }
-
- if ($filterValue) {
- $currentFilter[$field][$keyId] = $filterValue;
-
- $valueField = $nestedPath . '.' . $keyId . '.keyword';
- $productList->addCondition($filterValue, $valueField);
- }
- }
- }
-
- return $currentFilter;
- }
-}
diff --git a/src/FilterService/FilterType/ElasticSearch/SelectFromMultiSelect.php b/src/FilterService/FilterType/ElasticSearch/SelectFromMultiSelect.php
deleted file mode 100644
index 25d2a19e..00000000
--- a/src/FilterService/FilterType/ElasticSearch/SelectFromMultiSelect.php
+++ /dev/null
@@ -1,59 +0,0 @@
-prepareGroupByValues($this->getField($filterDefinition), true);
- }
-
- public function addCondition(AbstractFilterDefinitionType $filterDefinition, ProductListInterface $productList, array $currentFilter, array $params, bool $isPrecondition = false): array
- {
- $field = $this->getField($filterDefinition);
- $preSelect = $this->getPreSelect($filterDefinition);
-
- $value = $params[$field] ?? null;
- $isReload = $params['is_reload'] ?? null;
-
- if ($value == AbstractFilterType::EMPTY_STRING) {
- $value = null;
- } elseif (empty($value) && !$isReload) {
- $value = $preSelect;
- }
-
- if (!empty($value)) {
- $value = trim($value);
- }
-
- $currentFilter[$field] = $value;
-
- if (!empty($value)) {
- $productList->addCondition(['term' => ['attributes.' . $field => $value]], $field);
- }
-
- return $currentFilter;
- }
-}
diff --git a/src/FilterService/FilterType/ElasticSearch/SelectRelation.php b/src/FilterService/FilterType/ElasticSearch/SelectRelation.php
deleted file mode 100644
index 4f5cd8f6..00000000
--- a/src/FilterService/FilterType/ElasticSearch/SelectRelation.php
+++ /dev/null
@@ -1,58 +0,0 @@
-prepareGroupByValues($this->getField($filterDefinition), true);
- }
-
- public function addCondition(AbstractFilterDefinitionType $filterDefinition, ProductListInterface $productList, array $currentFilter, array $params, bool $isPrecondition = false): array
- {
- $field = $this->getField($filterDefinition);
- $preSelect = $this->getPreSelect($filterDefinition);
-
- $value = $params[$field] ?? null;
- $isReload = $params['is_reload'] ?? null;
-
- if (empty($value) && !$isReload) {
- $o = $preSelect;
- if (!empty($o)) {
- $value = $o;
- }
- } elseif ($value == AbstractFilterType::EMPTY_STRING) {
- $value = null;
- }
-
- $currentFilter[$field] = $value;
-
- if (!empty($value)) {
- $productList->addRelationCondition($field, $value);
- }
-
- return $currentFilter;
- }
-}
diff --git a/src/FilterService/FilterType/SearchIndex/MultiSelect.php b/src/FilterService/FilterType/SearchIndex/MultiSelect.php
index 9113ac7e..c202b05c 100644
--- a/src/FilterService/FilterType/SearchIndex/MultiSelect.php
+++ b/src/FilterService/FilterType/SearchIndex/MultiSelect.php
@@ -18,8 +18,8 @@
use Pimcore\Bundle\EcommerceFrameworkBundle\Exception\InvalidConfigException;
use Pimcore\Bundle\EcommerceFrameworkBundle\FilterService\FilterType\AbstractFilterType;
-use Pimcore\Bundle\EcommerceFrameworkBundle\IndexService\ProductList\OpenSearch\AbstractOpenSearch;
use Pimcore\Bundle\EcommerceFrameworkBundle\IndexService\ProductList\ProductListInterface;
+use Pimcore\Bundle\EcommerceFrameworkBundle\IndexService\ProductList\TenantConfigInterface;
use Pimcore\Bundle\EcommerceFrameworkBundle\Model\AbstractFilterDefinitionType;
use Pimcore\Model\DataObject\Fieldcollection\Data\FilterMultiSelect;
@@ -71,13 +71,13 @@ public function addCondition(AbstractFilterDefinitionType $filterDefinition, Pro
}
}
- if (!$productList instanceof AbstractOpenSearch) {
+ if (!$productList instanceof TenantConfigInterface) {
throw new InvalidConfigException('invalid configuration');
}
$tenantConfig = $productList->getTenantConfig();
$attributeConfig = $tenantConfig->getAttributeConfig()[$field];
- if ($attributeConfig['type'] == 'boolean') {
+ if ($attributeConfig['type'] === 'boolean') {
foreach ($quotedValues as $k => $v) {
$quotedValues[$k] = (bool)$v;
}
diff --git a/src/IndexService/Config/ElasticSearch.php b/src/IndexService/Config/ElasticSearch.php
index 95d962cb..9aef9067 100644
--- a/src/IndexService/Config/ElasticSearch.php
+++ b/src/IndexService/Config/ElasticSearch.php
@@ -32,7 +32,7 @@
* Default configuration for elastic search as product index implementation.
*
*/
-class ElasticSearch extends AbstractConfig implements MockupConfigInterface, ElasticSearchConfigInterface
+class ElasticSearch extends AbstractConfig implements MockupConfigInterface, SearchConfigInterface
{
use OptionsResolverTrait;
diff --git a/src/IndexService/Config/SearchConfigInterface.php b/src/IndexService/Config/SearchConfigInterface.php
index bb2c8f30..f8222428 100644
--- a/src/IndexService/Config/SearchConfigInterface.php
+++ b/src/IndexService/Config/SearchConfigInterface.php
@@ -17,25 +17,17 @@
namespace Pimcore\Bundle\EcommerceFrameworkBundle\IndexService\Config;
use Pimcore\Bundle\EcommerceFrameworkBundle\IndexService\SynonymProvider\SynonymProviderInterface;
-use Pimcore\Bundle\EcommerceFrameworkBundle\IndexService\Worker\WorkerInterface;
/**
- * Interface for IndexService Tenant Configurations using elastic search as index
+ * Interface for IndexService Tenant Configurations using a search server e.g. elastic or open search as index
*/
interface SearchConfigInterface extends ConfigInterface
{
/**
* returns condition for current subtenant
- *
*/
public function getSubTenantCondition(): array;
- /**
- * creates and returns tenant worker suitable for this tenant configuration
- *
- */
- public function getTenantWorker(): WorkerInterface;
-
/**
* Get an associative array of configured synonym providers.
* - key: the name of the synonym provider configuration, which is equivalent to the name of the configured filter
@@ -58,9 +50,6 @@ public function getFieldNameMapped(string $fieldName, bool $considerSubFieldName
/**
* returns short field name based on full field name
* also considers subfield names like name.analyzed etc.
- *
- *
- * @return false|int|string
*/
public function getReverseMappedFieldName(string $fullFieldName): bool|int|string;
}
diff --git a/src/IndexService/ProductList/ElasticSearch/AbstractElasticSearch.php b/src/IndexService/ProductList/ElasticSearch/AbstractElasticSearch.php
index 25dfd76b..cab65cde 100644
--- a/src/IndexService/ProductList/ElasticSearch/AbstractElasticSearch.php
+++ b/src/IndexService/ProductList/ElasticSearch/AbstractElasticSearch.php
@@ -20,12 +20,13 @@
use Pimcore\Bundle\EcommerceFrameworkBundle\Exception\InvalidConfigException;
use Pimcore\Bundle\EcommerceFrameworkBundle\Factory;
use Pimcore\Bundle\EcommerceFrameworkBundle\IndexService\Config\ElasticSearch;
-use Pimcore\Bundle\EcommerceFrameworkBundle\IndexService\Config\ElasticSearchConfigInterface;
+use Pimcore\Bundle\EcommerceFrameworkBundle\IndexService\Config\SearchConfigInterface;
use Pimcore\Bundle\EcommerceFrameworkBundle\IndexService\ProductList\ProductListInterface;
+use Pimcore\Bundle\EcommerceFrameworkBundle\IndexService\ProductList\TenantConfigInterface;
use Pimcore\Bundle\EcommerceFrameworkBundle\Model\AbstractCategory;
use Pimcore\Bundle\EcommerceFrameworkBundle\Model\IndexableInterface;
-abstract class AbstractElasticSearch implements ProductListInterface
+abstract class AbstractElasticSearch implements ProductListInterface, TenantConfigInterface
{
const LIMIT_UNLIMITED = -1;
@@ -52,7 +53,7 @@ abstract class AbstractElasticSearch implements ProductListInterface
protected string $tenantName;
- protected ElasticSearchConfigInterface $tenantConfig;
+ protected SearchConfigInterface $tenantConfig;
protected ?int $totalCount = null;
@@ -115,12 +116,8 @@ public function setSearchAggregation(array $searchAggregation): static
return $this;
}
- public function __construct(ElasticSearchConfigInterface $tenantConfig)
+ public function __construct(SearchConfigInterface $tenantConfig)
{
- trigger_error(
- 'ElasticSearchConfigInterface is deprecated. Use SearchConfigInterface instead.',
- E_USER_DEPRECATED
- );
$this->tenantName = $tenantConfig->getTenantName();
$this->tenantConfig = $tenantConfig;
}
@@ -1089,7 +1086,7 @@ protected function convertBucketValues(array $bucket): array
return $data;
}
- public function getTenantConfig(): ElasticSearchConfigInterface
+ public function getTenantConfig(): SearchConfigInterface
{
return $this->tenantConfig;
}
diff --git a/src/IndexService/ProductList/OpenSearch/AbstractOpenSearch.php b/src/IndexService/ProductList/OpenSearch/AbstractOpenSearch.php
index c963b4d7..48fcb4a5 100644
--- a/src/IndexService/ProductList/OpenSearch/AbstractOpenSearch.php
+++ b/src/IndexService/ProductList/OpenSearch/AbstractOpenSearch.php
@@ -22,11 +22,12 @@
use Pimcore\Bundle\EcommerceFrameworkBundle\IndexService\Config\OpenSearch;
use Pimcore\Bundle\EcommerceFrameworkBundle\IndexService\Config\SearchConfigInterface;
use Pimcore\Bundle\EcommerceFrameworkBundle\IndexService\ProductList\ProductListInterface;
+use Pimcore\Bundle\EcommerceFrameworkBundle\IndexService\ProductList\TenantConfigInterface;
use Pimcore\Bundle\EcommerceFrameworkBundle\IndexService\Worker\OpenSearch\AbstractOpenSearch as Worker;
use Pimcore\Bundle\EcommerceFrameworkBundle\Model\AbstractCategory;
use Pimcore\Bundle\EcommerceFrameworkBundle\Model\IndexableInterface;
-abstract class AbstractOpenSearch implements ProductListInterface
+abstract class AbstractOpenSearch implements ProductListInterface, TenantConfigInterface
{
const LIMIT_UNLIMITED = -1;
diff --git a/src/IndexService/Config/ElasticSearchConfigInterface.php b/src/IndexService/ProductList/TenantConfigInterface.php
similarity index 64%
rename from src/IndexService/Config/ElasticSearchConfigInterface.php
rename to src/IndexService/ProductList/TenantConfigInterface.php
index e0007178..c028753f 100644
--- a/src/IndexService/Config/ElasticSearchConfigInterface.php
+++ b/src/IndexService/ProductList/TenantConfigInterface.php
@@ -14,11 +14,11 @@
* @license http://www.pimcore.org/license GPLv3 and PCL
*/
-namespace Pimcore\Bundle\EcommerceFrameworkBundle\IndexService\Config;
+namespace Pimcore\Bundle\EcommerceFrameworkBundle\IndexService\ProductList;
-/**
- * @deprecated This interface will be removed in version 2.0.0 Use SearchConfigInterface instead.
- */
-interface ElasticSearchConfigInterface extends SearchConfigInterface
+use Pimcore\Bundle\EcommerceFrameworkBundle\IndexService\Config\SearchConfigInterface;
+
+interface TenantConfigInterface
{
+ public function getTenantConfig(): SearchConfigInterface;
}
diff --git a/src/IndexService/Worker/ElasticSearch/AbstractElasticSearch.php b/src/IndexService/Worker/ElasticSearch/AbstractElasticSearch.php
index 5a4bfac4..bd074321 100644
--- a/src/IndexService/Worker/ElasticSearch/AbstractElasticSearch.php
+++ b/src/IndexService/Worker/ElasticSearch/AbstractElasticSearch.php
@@ -20,11 +20,11 @@
use Elastic\Elasticsearch\Client;
use Elastic\Elasticsearch\Exception\ClientResponseException;
use Pimcore\Bundle\EcommerceFrameworkBundle\IndexService\Config\ElasticSearch;
-use Pimcore\Bundle\EcommerceFrameworkBundle\IndexService\Config\ElasticSearchConfigInterface;
use Pimcore\Bundle\EcommerceFrameworkBundle\IndexService\Config\SearchConfigInterface;
use Pimcore\Bundle\EcommerceFrameworkBundle\IndexService\Interpreter\RelationInterpreterInterface;
use Pimcore\Bundle\EcommerceFrameworkBundle\IndexService\ProductList\ProductListInterface;
-use Pimcore\Bundle\EcommerceFrameworkBundle\IndexService\Worker;
+use Pimcore\Bundle\EcommerceFrameworkBundle\IndexService\Worker\IndexRefreshInterface;
+use Pimcore\Bundle\EcommerceFrameworkBundle\IndexService\Worker\ProductCentricBatchProcessingWorker;
use Pimcore\Bundle\EcommerceFrameworkBundle\Model\IndexableInterface;
use Pimcore\Logger;
use Pimcore\Model\Tool\TmpStore;
@@ -34,7 +34,7 @@
/**
* @property ElasticSearch $tenantConfig
*/
-abstract class AbstractElasticSearch extends Worker\ProductCentricBatchProcessingWorker implements Worker\BatchProcessingWorkerInterface
+abstract class AbstractElasticSearch extends ProductCentricBatchProcessingWorker implements IndexRefreshInterface
{
const STORE_TABLE_NAME = 'ecommerceframework_productindex_store_elastic';
@@ -77,12 +77,8 @@ abstract class AbstractElasticSearch extends Worker\ProductCentricBatchProcessin
protected LoggerInterface $logger;
- public function __construct(ElasticSearchConfigInterface $tenantConfig, Connection $db, EventDispatcherInterface $eventDispatcher, LoggerInterface $pimcoreEcommerceEsLogger)
+ public function __construct(SearchConfigInterface $tenantConfig, Connection $db, EventDispatcherInterface $eventDispatcher, LoggerInterface $pimcoreEcommerceEsLogger)
{
- trigger_error(
- 'ElasticSearchConfigInterface is deprecated. Use SearchConfigInterface instead.',
- E_USER_DEPRECATED
- );
parent::__construct($tenantConfig, $db, $eventDispatcher);
$this->logger = $pimcoreEcommerceEsLogger;
$this->indexName = ($tenantConfig->getClientConfig('indexName')) ? strtolower($tenantConfig->getClientConfig('indexName')) : strtolower($this->name);
diff --git a/src/IndexService/Worker/IndexRefreshInterface.php b/src/IndexService/Worker/IndexRefreshInterface.php
new file mode 100644
index 00000000..b4c365f0
--- /dev/null
+++ b/src/IndexService/Worker/IndexRefreshInterface.php
@@ -0,0 +1,28 @@
+