From 290b3932e16065c6bf217a635a03962a8f454acd Mon Sep 17 00:00:00 2001 From: michal-myszka <34576224+michal-myszka@users.noreply.github.com> Date: Fri, 31 Jan 2020 12:16:20 +0100 Subject: [PATCH] EZP-31226: Injected MaxDepth into FullText Criteria * Added MaxDepth parameter for Content and Location FullText Criteria * Set default max depth=2 for integration tests * [SF4 forward compatibility] Implemented factory for IndexingDepthProvider (back-ported from #141) * Refactored max-depth parameter providing Co-authored-by: Andrew Longosz --- .../Factory/FullTextFactoryAbstract.php | 84 +++++++++++++++++++ .../Factory/ContentFullTextFactory.php | 39 +++++++++ .../Factory/LocationFullTextFactory.php | 39 +++++++++ .../container/solr/criterion_visitors.yml | 28 ++++--- tests/lib/Resources/config/cloud.yml | 1 + tests/lib/Resources/config/common.yml | 1 + .../Resources/config/multicore_dedicated.yml | 1 + .../lib/Resources/config/multicore_shared.yml | 1 + tests/lib/Resources/config/single_core.yml | 1 + .../CriterionVisitor/FullTextTest.php | 2 +- 10 files changed, 185 insertions(+), 12 deletions(-) create mode 100644 lib/Query/Common/CriterionVisitor/Factory/FullTextFactoryAbstract.php create mode 100644 lib/Query/Content/CriterionVisitor/Factory/ContentFullTextFactory.php create mode 100644 lib/Query/Location/CriterionVisitor/Factory/LocationFullTextFactory.php rename tests/lib/Search/Query/{ => Content}/CriterionVisitor/FullTextTest.php (99%) diff --git a/lib/Query/Common/CriterionVisitor/Factory/FullTextFactoryAbstract.php b/lib/Query/Common/CriterionVisitor/Factory/FullTextFactoryAbstract.php new file mode 100644 index 000000000..7126b69c1 --- /dev/null +++ b/lib/Query/Common/CriterionVisitor/Factory/FullTextFactoryAbstract.php @@ -0,0 +1,84 @@ +fieldNameResolver = $fieldNameResolver; + $this->tokenizer = $tokenizer; + $this->parser = $parser; + $this->generator = $generator; + $this->indexingDepthProvider = $indexingDepthProvider; + } + + /** + * Create FullText Criterion Visitor. + * + * @return \EzSystems\EzPlatformSolrSearchEngine\Query\CriterionVisitor + */ + abstract public function createCriterionVisitor(): CriterionVisitor; +} diff --git a/lib/Query/Content/CriterionVisitor/Factory/ContentFullTextFactory.php b/lib/Query/Content/CriterionVisitor/Factory/ContentFullTextFactory.php new file mode 100644 index 000000000..0e6d012d0 --- /dev/null +++ b/lib/Query/Content/CriterionVisitor/Factory/ContentFullTextFactory.php @@ -0,0 +1,39 @@ +fieldNameResolver, + $this->tokenizer, + $this->parser, + $this->generator, + $this->indexingDepthProvider->getMaxDepth() + ); + } +} diff --git a/lib/Query/Location/CriterionVisitor/Factory/LocationFullTextFactory.php b/lib/Query/Location/CriterionVisitor/Factory/LocationFullTextFactory.php new file mode 100644 index 000000000..e2ecbbe5f --- /dev/null +++ b/lib/Query/Location/CriterionVisitor/Factory/LocationFullTextFactory.php @@ -0,0 +1,39 @@ +fieldNameResolver, + $this->tokenizer, + $this->parser, + $this->generator, + $this->indexingDepthProvider->getMaxDepth() + ); + } +} diff --git a/lib/Resources/config/container/solr/criterion_visitors.yml b/lib/Resources/config/container/solr/criterion_visitors.yml index 46e106f2e..e46e39cb7 100644 --- a/lib/Resources/config/container/solr/criterion_visitors.yml +++ b/lib/Resources/config/container/solr/criterion_visitors.yml @@ -242,6 +242,15 @@ services: - {name: ezpublish.search.solr.query.content.criterion_visitor} - {name: ezpublish.search.solr.query.location.criterion_visitor} + EzSystems\EzPlatformSolrSearchEngine\Query\Common\CriterionVisitor\Factory\FullTextFactoryAbstract: + abstract: true + arguments: + - "@ezpublish.search.common.field_name_resolver" + - "@ezpublish.search.solr.query.query_translator.galach.tokenizer" + - "@ezpublish.search.solr.query.query_translator.galach.parser" + - "@ezpublish.search.solr.query.query_translator.galach.generator.edismax" + - "@ezpublish.search.solr.field_mapper.indexing_depth_provider" + # Content search ezpublish.search.solr.query.content.criterion_visitor.ancestor: class: "%ezpublish.search.solr.query.content.criterion_visitor.ancestor.class%" @@ -270,15 +279,13 @@ services: ezpublish.search.solr.query.content.criterion_visitor.full_text: class: "%ezpublish.search.solr.query.content.criterion_visitor.full_text.class%" - arguments: - - "@ezpublish.search.common.field_name_resolver" - - "@ezpublish.search.solr.query.query_translator.galach.tokenizer" - - "@ezpublish.search.solr.query.query_translator.galach.parser" - - "@ezpublish.search.solr.query.query_translator.galach.generator.edismax" - - "@=service('ezpublish.search.solr.field_mapper.indexing_depth_provider').getMaxDepth()" + factory: ['@EzSystems\EzPlatformSolrSearchEngine\Query\Content\CriterionVisitor\Factory\ContentFullTextFactory', 'createCriterionVisitor'] tags: - {name: ezpublish.search.solr.query.content.criterion_visitor} + EzSystems\EzPlatformSolrSearchEngine\Query\Content\CriterionVisitor\Factory\ContentFullTextFactory: + parent: EzSystems\EzPlatformSolrSearchEngine\Query\Common\CriterionVisitor\Factory\FullTextFactoryAbstract + ezpublish.search.solr.query.content.criterion_visitor.visibility: class: "%ezpublish.search.solr.query.content.criterion_visitor.visibility.class%" tags: @@ -342,10 +349,9 @@ services: ezpublish.search.solr.query.location.criterion_visitor.full_text: class: "%ezpublish.search.solr.query.location.criterion_visitor.full_text.class%" - arguments: - - "@ezpublish.search.common.field_name_resolver" - - "@ezpublish.search.solr.query.query_translator.galach.tokenizer" - - "@ezpublish.search.solr.query.query_translator.galach.parser" - - "@ezpublish.search.solr.query.query_translator.galach.generator.edismax" + factory: ['@EzSystems\EzPlatformSolrSearchEngine\Query\Location\CriterionVisitor\Factory\LocationFullTextFactory', 'createCriterionVisitor'] tags: - {name: ezpublish.search.solr.query.location.criterion_visitor} + + EzSystems\EzPlatformSolrSearchEngine\Query\Location\CriterionVisitor\Factory\LocationFullTextFactory: + parent: EzSystems\EzPlatformSolrSearchEngine\Query\Common\CriterionVisitor\Factory\FullTextFactoryAbstract diff --git a/tests/lib/Resources/config/cloud.yml b/tests/lib/Resources/config/cloud.yml index dcf761fd1..222b04319 100644 --- a/tests/lib/Resources/config/cloud.yml +++ b/tests/lib/Resources/config/cloud.yml @@ -28,6 +28,7 @@ parameters: ger-DE: ger # cloud@shard3 ezpublish.search.solr.default_endpoint: default # cloud@shard2 ezpublish.search.solr.main_translations_endpoint: main # cloud@shard1 + ezpublish.search.solr.field_mapper.indexing_depth_provider.default: 2 services: ezpublish.spi.search_engine: diff --git a/tests/lib/Resources/config/common.yml b/tests/lib/Resources/config/common.yml index 42471fdf1..55019ddf4 100644 --- a/tests/lib/Resources/config/common.yml +++ b/tests/lib/Resources/config/common.yml @@ -1,5 +1,6 @@ parameters: ezpublish.signalslot.signal_dispatcher.factory.class: eZ\Publish\Core\Base\Container\ApiLoader\SignalSlot\SignalDispatcherFactory + ezpublish.search.solr.field_mapper.indexing_depth_provider.default: 2 services: ezpublish.signalslot.signal_dispatcher.factory: diff --git a/tests/lib/Resources/config/multicore_dedicated.yml b/tests/lib/Resources/config/multicore_dedicated.yml index 83b079165..ae99e9009 100644 --- a/tests/lib/Resources/config/multicore_dedicated.yml +++ b/tests/lib/Resources/config/multicore_dedicated.yml @@ -26,6 +26,7 @@ parameters: nor-NO: endpoint4 ezpublish.search.solr.default_endpoint: null ezpublish.search.solr.main_translations_endpoint: null + ezpublish.search.solr.field_mapper.indexing_depth_provider.default: 2 services: ezpublish.spi.search_engine: diff --git a/tests/lib/Resources/config/multicore_shared.yml b/tests/lib/Resources/config/multicore_shared.yml index dc00de724..27f9205a8 100644 --- a/tests/lib/Resources/config/multicore_shared.yml +++ b/tests/lib/Resources/config/multicore_shared.yml @@ -22,6 +22,7 @@ parameters: eng-GB: endpoint3 ezpublish.search.solr.default_endpoint: endpoint2 ezpublish.search.solr.main_translations_endpoint: endpoint0 + ezpublish.search.solr.field_mapper.indexing_depth_provider.default: 2 services: ezpublish.spi.search_engine: diff --git a/tests/lib/Resources/config/single_core.yml b/tests/lib/Resources/config/single_core.yml index 6a553647c..36a041355 100644 --- a/tests/lib/Resources/config/single_core.yml +++ b/tests/lib/Resources/config/single_core.yml @@ -21,6 +21,7 @@ parameters: ezpublish.search.solr.cluster_endpoints: [] ezpublish.search.solr.default_endpoint: endpoint0 ezpublish.search.solr.main_translations_endpoint: null + ezpublish.search.solr.field_mapper.indexing_depth_provider.default: 2 services: ezpublish.spi.search_engine: diff --git a/tests/lib/Search/Query/CriterionVisitor/FullTextTest.php b/tests/lib/Search/Query/Content/CriterionVisitor/FullTextTest.php similarity index 99% rename from tests/lib/Search/Query/CriterionVisitor/FullTextTest.php rename to tests/lib/Search/Query/Content/CriterionVisitor/FullTextTest.php index 4eec7f48f..0998f456c 100644 --- a/tests/lib/Search/Query/CriterionVisitor/FullTextTest.php +++ b/tests/lib/Search/Query/Content/CriterionVisitor/FullTextTest.php @@ -8,7 +8,7 @@ * * @version //autogentag// */ -namespace EzSystems\EzPlatformSolrSearchEngine\Tests\Search\Query\CriterionVisitor; +namespace EzSystems\EzPlatformSolrSearchEngine\Tests\Search\Query\Content\CriterionVisitor; use eZ\Publish\API\Repository\Values\Content\Query\Criterion; use eZ\Publish\Core\FieldType\TextLine\SearchField;