Skip to content

Commit

Permalink
EZP-31226: Injected MaxDepth into FullText Criteria
Browse files Browse the repository at this point in the history
* 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 <alongosz@users.noreply.github.com>
  • Loading branch information
michal-myszka and alongosz authored Jan 31, 2020
1 parent d9d54e3 commit 290b393
Show file tree
Hide file tree
Showing 10 changed files with 185 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
<?php

/**
* @copyright Copyright (C) eZ Systems AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/
declare(strict_types=1);

namespace EzSystems\EzPlatformSolrSearchEngine\Query\Common\CriterionVisitor\Factory;

use eZ\Publish\Core\Search\Common\FieldNameResolver;
use EzSystems\EzPlatformSolrSearchEngine\FieldMapper\IndexingDepthProvider;
use EzSystems\EzPlatformSolrSearchEngine\Query\CriterionVisitor;
use QueryTranslator\Languages\Galach\Generators\ExtendedDisMax;
use QueryTranslator\Languages\Galach\Parser;
use QueryTranslator\Languages\Galach\Tokenizer;

/**
* Factory for FullText Criterion Visitor.
*
* @see \EzSystems\EzPlatformSolrSearchEngine\Query\Content\CriterionVisitor\FullText
* @see \EzSystems\EzPlatformSolrSearchEngine\Query\Location\CriterionVisitor\FullText
*
* @internal
*/
abstract class FullTextFactoryAbstract
{
/**
* Field map.
*
* @var \eZ\Publish\Core\Search\Common\FieldNameResolver
*/
protected $fieldNameResolver;

/**
* @var \QueryTranslator\Languages\Galach\Tokenizer
*/
protected $tokenizer;

/**
* @var \QueryTranslator\Languages\Galach\Parser
*/
protected $parser;

/**
* @var \QueryTranslator\Languages\Galach\Generators\ExtendedDisMax
*/
protected $generator;

/**
* @var \EzSystems\EzPlatformSolrSearchEngine\FieldMapper\IndexingDepthProvider
*/
protected $indexingDepthProvider;

/**
* Create from content type handler and field registry.
*
* @param \eZ\Publish\Core\Search\Common\FieldNameResolver $fieldNameResolver
* @param \QueryTranslator\Languages\Galach\Tokenizer $tokenizer
* @param \QueryTranslator\Languages\Galach\Parser $parser
* @param \QueryTranslator\Languages\Galach\Generators\ExtendedDisMax $generator
* @param \EzSystems\EzPlatformSolrSearchEngine\FieldMapper\IndexingDepthProvider $indexingDepthProvider
*/
public function __construct(
FieldNameResolver $fieldNameResolver,
Tokenizer $tokenizer,
Parser $parser,
ExtendedDisMax $generator,
IndexingDepthProvider $indexingDepthProvider
) {
$this->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;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

/**
* @copyright Copyright (C) eZ Systems AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/
declare(strict_types=1);

namespace EzSystems\EzPlatformSolrSearchEngine\Query\Content\CriterionVisitor\Factory;

use EzSystems\EzPlatformSolrSearchEngine\Query\Common\CriterionVisitor\Factory\FullTextFactoryAbstract;
use EzSystems\EzPlatformSolrSearchEngine\Query\Content\CriterionVisitor\FullText;
use EzSystems\EzPlatformSolrSearchEngine\Query\CriterionVisitor;

/**
* Factory for FullText Criterion Visitor.
*
* @see \EzSystems\EzPlatformSolrSearchEngine\Query\Content\CriterionVisitor\FullText
*
* @internal
*/
final class ContentFullTextFactory extends FullTextFactoryAbstract
{
/**
* Create FullText Criterion Visitor.
*
* @return \EzSystems\EzPlatformSolrSearchEngine\Query\CriterionVisitor|\EzSystems\EzPlatformSolrSearchEngine\Query\Content\CriterionVisitor\FullText
*/
public function createCriterionVisitor(): CriterionVisitor
{
return new FullText(
$this->fieldNameResolver,
$this->tokenizer,
$this->parser,
$this->generator,
$this->indexingDepthProvider->getMaxDepth()
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

/**
* @copyright Copyright (C) eZ Systems AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/
declare(strict_types=1);

namespace EzSystems\EzPlatformSolrSearchEngine\Query\Location\CriterionVisitor\Factory;

use EzSystems\EzPlatformSolrSearchEngine\Query\Common\CriterionVisitor\Factory\FullTextFactoryAbstract;
use EzSystems\EzPlatformSolrSearchEngine\Query\CriterionVisitor;
use EzSystems\EzPlatformSolrSearchEngine\Query\Location\CriterionVisitor\FullText;

/**
* Factory for FullText Criterion Visitor.
*
* @see \EzSystems\EzPlatformSolrSearchEngine\Query\Content\CriterionVisitor\FullText
*
* @internal
*/
final class LocationFullTextFactory extends FullTextFactoryAbstract
{
/**
* Create FullText Criterion Visitor.
*
* @return \EzSystems\EzPlatformSolrSearchEngine\Query\CriterionVisitor|\EzSystems\EzPlatformSolrSearchEngine\Query\Location\CriterionVisitor\FullText
*/
public function createCriterionVisitor(): CriterionVisitor
{
return new FullText(
$this->fieldNameResolver,
$this->tokenizer,
$this->parser,
$this->generator,
$this->indexingDepthProvider->getMaxDepth()
);
}
}
28 changes: 17 additions & 11 deletions lib/Resources/config/container/solr/criterion_visitors.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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%"
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
1 change: 1 addition & 0 deletions tests/lib/Resources/config/cloud.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions tests/lib/Resources/config/common.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
1 change: 1 addition & 0 deletions tests/lib/Resources/config/multicore_dedicated.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions tests/lib/Resources/config/multicore_shared.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions tests/lib/Resources/config/single_core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 290b393

Please sign in to comment.