Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance search customization #2591

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions code_samples/search/custom/config/aggregation_services.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
services:
app.search.solr.query.aggregation_visitor.priority_range_aggregation:
class: Ibexa\Solr\Query\Common\AggregationVisitor\RangeAggregationVisitor
factory: [ '@Ibexa\Solr\Query\Common\AggregationVisitor\Factory\SearchFieldAggregationVisitorFactory', 'createRangeAggregationVisitor' ]
arguments:
$aggregationClass: 'App\Query\Aggregation\Solr\PriorityRangeAggregation'
$searchIndexFieldName: 'priority_i'
tags:
- { name: ibexa.search.solr.query.content.aggregation.visitor }
- { name: ibexa.search.solr.query.location.aggregation.visitor }

app.search.elasticsearch.query.aggregation_visitor.priority_range_aggregation:
class: Ibexa\Elasticsearch\Query\AggregationVisitor\RangeAggregationVisitor
factory: [ '@Ibexa\Elasticsearch\Query\AggregationVisitor\Factory\SearchFieldAggregationVisitorFactory', 'createRangeAggregationVisitor' ]
arguments:
$aggregationClass: 'App\Query\Aggregation\Elasticsearch\PriorityRangeAggregation'
$searchIndexFieldName: 'priority_i'
tags:
- { name: ibexa.search.elasticsearch.query.location.aggregation.visitor }
- { name: ibexa.search.elasticsearch.query.content.aggregation.visitor }

app.search.solr.query.aggregation_result_extractor.priority_range_aggregation:
class: Ibexa\Solr\ResultExtractor\AggregationResultExtractor\RangeAggregationResultExtractor
arguments:
$aggregationClass: 'App\Query\Aggregation\Solr\PriorityRangeAggregation'
$keyMapper: 'Ibexa\Solr\ResultExtractor\AggregationResultExtractor\RangeAggregationKeyMapper\IntRangeAggregationKeyMapper'
tags:
- { name: ibexa.search.solr.query.location.aggregation.result.extractor }
- { name: ibexa.search.solr.query.content.aggregation.result.extractor }

app.search.elasticsearch.query.aggregation_result_extractor.priority_range_aggregation:
class: Ibexa\Elasticsearch\Query\ResultExtractor\AggregationResultExtractor\RangeAggregationResultExtractor
arguments:
$aggregationClass: 'App\Query\Aggregation\Elasticsearch\PriorityRangeAggregation'
tags:
- { name: ibexa.search.elasticsearch.query.location.aggregation.result.extractor }
- { name: ibexa.search.elasticsearch.query.content.aggregation.result.extractor }

App\Query\Aggregation\Solr\PriorityRangeAggregationVisitor:
tags:
- { name: ibexa.search.solr.query.location.aggregation.visitor }
- { name: ibexa.search.solr.query.content.aggregation.visitor }

App\Query\Aggregation\Solr\PriorityRangeAggregationResultExtractor:
tags:
- { name: ibexa.search.solr.query.location.aggregation.result.extractor }
- { name: ibexa.search.solr.query.content.aggregation.result.extractor }

App\Query\Aggregation\Elasticsearch\PriorityRangeAggregationVisitor:
tags:
- { name: ibexa.search.elasticsearch.query.location.aggregation.visitor }
- { name: ibexa.search.elasticsearch.query.content.aggregation.visitor }

App\Query\Aggregation\Elasticsearch\PriorityRangeAggregationResultExtractor:
tags:
- { name: ibexa.search.elasticsearch.query.location.aggregation.result.extractor }
- { name: ibexa.search.elasticsearch.query.content.aggregation.result.extractor }
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
services:
App\Query\Criterion\Solr\CameraManufacturerVisitor:
tags:
- { name: ibexa.search.solr.query.content.criterion.visitor }
- { name: ibexa.search.solr.query.location.criterion.visitor }

App\Query\Criterion\Elasticsearch\CameraManufacturerVisitor:
tags:
- { name: ibexa.search.elasticsearch.query.content.criterion.visitor }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
services:
App\Query\SortClause\Solr\ScoreVisitor:
tags:
- { name: ibexa.search.solr.query.content.sort_clause.visitor }
- { name: ibexa.search.solr.query.location.sort_clause.visitor }

App\Query\SortClause\Elasticsearch\ScoreVisitor:
tags:
- { name: ibexa.search.elasticsearch.query.content.sort_clause.visitor }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@

namespace App\Query\Aggregation\Elasticsearch;

use App\Query\Aggregation\PriorityRangeAggregation;
use Ibexa\Contracts\Core\Repository\Values\Content\Query\Aggregation;
use Ibexa\Contracts\Core\Repository\Values\Content\Search\AggregationResult;
use Ibexa\Contracts\Elasticsearch\Query\AggregationResultExtractor;
use Ibexa\Contracts\Elasticsearch\Query\LanguageFilter;

final class PriorityAggregationResultExtractor implements AggregationResultExtractor
final class PriorityRangeAggregationResultExtractor implements AggregationResultExtractor
{
public function supports(Aggregation $aggregation, LanguageFilter $languageFilter): bool
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,20 @@

namespace App\Query\Aggregation\Elasticsearch;

use App\Query\Aggregation\PriorityRangeAggregation;
use Ibexa\Contracts\Core\Repository\Values\Content\Query\Aggregation;
use Ibexa\Contracts\Elasticsearch\Query\AggregationVisitor;
use Ibexa\Contracts\Elasticsearch\Query\LanguageFilter;

final class PriorityAggregationVisitor implements AggregationVisitor
final class PriorityRangeAggregationVisitor implements AggregationVisitor
{
public function supports(Aggregation $aggregation, LanguageFilter $languageFilter): bool
{
return $aggregation instanceof PriorityRangeAggregation;
}

/**
* @param PriorityRangeAggregation $aggregation
* @param \App\Query\Aggregation\PriorityRangeAggregation $aggregation
*/
public function visit(AggregationVisitor $dispatcher, Aggregation $aggregation, LanguageFilter $languageFilter): array
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace App\Query\Aggregation\Solr;
namespace App\Query\Aggregation;

use Ibexa\Contracts\Core\Repository\Values\Content\Query\Aggregation\AbstractRangeAggregation;
use Ibexa\Contracts\Core\Repository\Values\Content\Query\Aggregation\LocationAggregation;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace App\Query\Aggregation\Solr;

use App\Query\Aggregation\PriorityRangeAggregation;
use Ibexa\Contracts\Core\Repository\Values\Content\Query\Aggregation;
use Ibexa\Contracts\Core\Repository\Values\Content\Query\Aggregation\Range;
use Ibexa\Contracts\Core\Repository\Values\Content\Search\AggregationResult;
Expand All @@ -12,7 +13,7 @@
use Ibexa\Contracts\Solr\ResultExtractor\AggregationResultExtractor;
use stdClass;

final class PriorityAggregationResultExtractor implements AggregationResultExtractor
final class PriorityRangeAggregationResultExtractor implements AggregationResultExtractor
{
public function canVisit(Aggregation $aggregation, array $languageFilter): bool
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace App\Query\Aggregation\Solr;

use App\Query\Aggregation\PriorityRangeAggregation;
use Ibexa\Contracts\Core\Repository\Values\Content\Query\Aggregation;
use Ibexa\Contracts\Solr\Query\AggregationVisitor;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace App\Query\Criterion\Solr;
namespace App\Query\Criterion;

use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion;
use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\Operator;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace App\Query\Criterion\Elasticsearch;

use App\Query\Criterion\CameraManufacturerCriterion;
use Ibexa\Contracts\Core\Repository\Values\Content\Query\CriterionInterface;
use Ibexa\Contracts\Elasticsearch\Query\CriterionVisitor;
use Ibexa\Contracts\Elasticsearch\Query\LanguageFilter;
Expand All @@ -16,7 +17,7 @@ public function supports(CriterionInterface $criterion, LanguageFilter $language
}

/**
* @param \App\Query\Criterion\Elasticsearch\CameraManufacturerCriterion $criterion
* @param \App\Query\Criterion\CameraManufacturerCriterion $criterion
*/
public function visit(CriterionVisitor $dispatcher, CriterionInterface $criterion, LanguageFilter $languageFilter): array
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace App\Query\Criterion\Solr;

use App\Query\Criterion\CameraManufacturerCriterion;
use Ibexa\Contracts\Core\Repository\Values\Content\Query\CriterionInterface;
use Ibexa\Contracts\Solr\Query\CriterionVisitor;

Expand All @@ -15,7 +16,7 @@ public function canVisit(CriterionInterface $criterion)
}

/**
* @param \App\Query\Criterion\Solr\CameraManufacturerCriterion $criterion
* @param \App\Query\Criterion\CameraManufacturerCriterion $criterion
*/
public function visit(CriterionInterface $criterion, CriterionVisitor $subVisitor = null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace App\Query\SortClause\Elasticsearch;

use App\Query\SortClause\ScoreSortClause;
use Ibexa\Contracts\Core\Repository\Values\Content\Query;
use Ibexa\Contracts\Core\Repository\Values\Content\Query\SortClause;
use Ibexa\Contracts\Elasticsearch\Query\LanguageFilter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace App\Query\SortClause\Solr;
namespace App\Query\SortClause;

use Ibexa\Contracts\Core\Repository\Values\Content\Query;
use Ibexa\Contracts\Core\Repository\Values\Content\Query\SortClause;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@

namespace App\Query\SortClause\Solr;

use App\Query\SortClause\ScoreSortClause;
use Ibexa\Contracts\Core\Repository\Values\Content\Query\SortClause;
use Ibexa\Contracts\Solr\Query\SortClauseVisitor;

class ScoreVisitor extends SortClauseVisitor
{
public function canVisit(SortClause $sortClause): bool
{
return $sortClause instanceof SortClause\Score;
return $sortClause instanceof ScoreSortClause;
}

public function visit(SortClause $sortClause): string
Expand Down
10 changes: 0 additions & 10 deletions code_samples/search/elasticsearch/config/aggregation_services.yaml

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

10 changes: 0 additions & 10 deletions code_samples/search/solr/config/aggregation_services.yaml

This file was deleted.

5 changes: 0 additions & 5 deletions code_samples/search/solr/config/criterion_services.yaml

This file was deleted.

5 changes: 0 additions & 5 deletions code_samples/search/solr/config/sort_clause_services.yaml

This file was deleted.

Loading
Loading