diff --git a/src/module-elasticsuite-core/Search/Request/Query/Fulltext/QueryBuilder.php b/src/module-elasticsuite-core/Search/Request/Query/Fulltext/QueryBuilder.php index 21bb3ed7c..ef8954843 100644 --- a/src/module-elasticsuite-core/Search/Request/Query/Fulltext/QueryBuilder.php +++ b/src/module-elasticsuite-core/Search/Request/Query/Fulltext/QueryBuilder.php @@ -100,8 +100,8 @@ public function create(ContainerConfigurationInterface $containerConfig, $queryT $relevanceConfig = $containerConfig->getRelevanceConfig(); if ($relevanceConfig->getSpanMatchBoost()) { $spanQuery = $this->getSpanQuery($containerConfig, $queryText, $relevanceConfig->getSpanMatchBoost()); - $spanQuery->setName('SPAN'); if ($spanQuery !== null) { + $spanQuery->setName('SPAN'); $queryParams = [ 'must' => [$query], 'should' => [$spanQuery], diff --git a/src/module-elasticsuite-thesaurus/Model/Index.php b/src/module-elasticsuite-thesaurus/Model/Index.php index 1613a315b..028842063 100644 --- a/src/module-elasticsuite-thesaurus/Model/Index.php +++ b/src/module-elasticsuite-thesaurus/Model/Index.php @@ -173,8 +173,9 @@ private function getCacheKey(ContainerConfigurationInterface $containerConfig, $ private function getCacheTags(ContainerConfigurationInterface $containerConfig) { $storeId = $containerConfig->getStoreId(); + $containerName = $containerConfig->getName(); - return [$this->getIndexAlias($storeId)]; + return [$this->getIndexAlias($storeId), $containerName]; } /** @@ -217,7 +218,7 @@ private function getConfig(ContainerConfigurationInterface $containerConfig) private function getSynonymRewrites($storeId, $queryText, $type, $maxRewrites) { $indexName = $this->getIndexAlias($storeId); - $analyzedQueries = $this->getQueryCombinations($storeId, $queryText); + $analyzedQueries = $this->getQueryCombinations($storeId, str_replace('-', ' ', $queryText)); $synonyms = []; foreach ($analyzedQueries as $query) { diff --git a/src/module-elasticsuite-virtual-category/Model/Rule.php b/src/module-elasticsuite-virtual-category/Model/Rule.php index f515f243c..1dc3845cc 100644 --- a/src/module-elasticsuite-virtual-category/Model/Rule.php +++ b/src/module-elasticsuite-virtual-category/Model/Rule.php @@ -424,7 +424,16 @@ private function getVirtualCategoryQuery( $excludedCategories = [] ): ?QueryInterface { $rootCategory = $this->getVirtualRootCategory($category); - if ($rootCategory && in_array($rootCategory->getId(), $excludedCategories)) { + // If the root category of the current virtual category has already been computed (exist in $excludedCategories) + // or if a parent of the root category of the current category has already been computed we don't need + // to compute the rule. All the product will already been present. + // For example, if you have the following category tree: + // - Category A (static) + // - - Category B (static) + // - - Category C (virtual with category B as root) + // When you compute the rule of the category A you do not need to compute the rule of the category C + // as all the product will be there. + if ($rootCategory && array_intersect(explode('/', $rootCategory->getPath()), $excludedCategories)) { return null; }