-
Notifications
You must be signed in to change notification settings - Fork 82
Enhance search customization #2591
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
Merged
Merged
Changes from 31 commits
Commits
Show all changes
33 commits
Select commit
Hold shift + click to select a range
4028a27
Merge ElasticSearch and Solr custom criterion, sort clause and aggreg…
adriendupuis 0cfc503
PHP CS Fixes
adriendupuis 30a9151
Update phpstan-baseline.neon
adriendupuis b7dd166
Update phpstan-baseline.neon
adriendupuis d44d436
Update phpstan-baseline.neon
adriendupuis ec0c31f
aggregation_services.yaml: Fix base visitor classes
adriendupuis cedc245
aggregation_services.yaml: Fix priority_range_aggregation factory
adriendupuis 497b243
create_custom_search_criterion.md: Links to custom index pages
adriendupuis 65ede71
create_custom_aggregation.md: Add a class section
adriendupuis e162148
create_custom_aggregation.md: Narrow usage to location
adriendupuis a8cd54e
create_custom_aggregation.md: Introduce Solr's $keyMapper
adriendupuis e160ab1
create_custom_aggregation.md: Sort aggregation types
adriendupuis 4df9600
create_custom_aggregation.md: Add links to PHP API Ref, Fix FQCN
adriendupuis bb2894c
solr_document_field_mappers.md: Links to PHP API Ref
adriendupuis 5bab11a
index_custom_elasticsearch_data.md: Links to PHP API Ref
adriendupuis e5c9500
index_custom_elasticsearch_data.md: Links to PHP API Ref
adriendupuis 5886003
index_custom_elasticsearch_data.md: service registration is not manda…
adriendupuis 04c0c79
customize_elasticsearch_index_structure.md: Indicate CompositeGroupRe…
adriendupuis 60188d9
manipulate_elasticsearch_query.md: Link to PHP API Ref
adriendupuis 474dd36
manipulate_elasticsearch_query.md: Fix redundancy
adriendupuis 3f7c13c
manipulate_elasticsearch_query.md: service registration is not mandatory
adriendupuis ad59fb7
Move Elasticsearch subscribers to code_samples/ PHP files
adriendupuis e40ce72
PHP CS Fixes
adriendupuis 43e98f8
build.yaml: Avoid too long code_samples_usage.diff.md
adriendupuis a98cdab
Merge branch 'master' into enh-custom-search
adriendupuis 3433f9b
build.yaml: Avoid too long code_samples_usage.diff.md
adriendupuis e15db11
create_custom_aggregation.md: Explain why only location tag, fix tag.
adriendupuis 9ee8733
Merge branch 'master' into enh-custom-search
adriendupuis 2dbf67b
build.yaml: Avoid too long code_samples_usage.diff.md
adriendupuis 5aef3cb
build.yaml: Avoid too long code_samples_usage.diff.md
adriendupuis 130f30b
build.yaml: Avoid too long code_samples_usage.diff.md
adriendupuis 8159cde
search/extensibility/*.md: Symfony's autoconfiguration
adriendupuis 8da31d0
Apply suggestions from code review
adriendupuis File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
code_samples/search/custom/config/aggregation_services.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
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.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 } | ||
|
||
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 } | ||
|
||
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 } | ||
|
||
App\Query\Aggregation\Solr\PriorityRangeAggregationVisitor: | ||
tags: | ||
- { name: ibexa.search.solr.query.location.aggregation.visitor } | ||
|
||
App\Query\Aggregation\Solr\PriorityRangeAggregationResultExtractor: | ||
tags: | ||
- { name: ibexa.search.solr.query.location.aggregation.result.extractor } | ||
|
||
App\Query\Aggregation\Elasticsearch\PriorityRangeAggregationVisitor: | ||
tags: | ||
- { name: ibexa.search.elasticsearch.query.location.aggregation.visitor } | ||
|
||
App\Query\Aggregation\Elasticsearch\PriorityRangeAggregationResultExtractor: | ||
tags: | ||
- { name: ibexa.search.elasticsearch.query.location.aggregation.result.extractor } |
5 changes: 5 additions & 0 deletions
5
...sticsearch/config/criterion_services.yaml → ...rch/custom/config/criterion_services.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
5 changes: 5 additions & 0 deletions
5
...icsearch/config/sort_clause_services.yaml → ...h/custom/config/sort_clause_services.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
code_samples/search/custom/src/EventSubscriber/CustomIndexDataSubscriber.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\EventSubscriber; | ||
|
||
use Ibexa\Contracts\Core\Search\Field; | ||
use Ibexa\Contracts\Core\Search\FieldType\StringField; | ||
use Ibexa\Contracts\Elasticsearch\Mapping\Event\ContentIndexCreateEvent; | ||
use Ibexa\Contracts\Elasticsearch\Mapping\Event\LocationIndexCreateEvent; | ||
use Symfony\Component\EventDispatcher\EventSubscriberInterface; | ||
|
||
final class CustomIndexDataSubscriber implements EventSubscriberInterface | ||
{ | ||
public function onContentDocumentCreate(ContentIndexCreateEvent $event): void | ||
{ | ||
$document = $event->getDocument(); | ||
$document->fields[] = new Field( | ||
'custom_field', | ||
'Custom field value', | ||
new StringField() | ||
); | ||
} | ||
|
||
public function onLocationDocumentCreate(LocationIndexCreateEvent $event): void | ||
{ | ||
$document = $event->getDocument(); | ||
$document->fields[] = new Field( | ||
'custom_field', | ||
'Custom field value', | ||
new StringField() | ||
); | ||
} | ||
|
||
public static function getSubscribedEvents(): array | ||
{ | ||
return [ | ||
ContentIndexCreateEvent::class => 'onContentDocumentCreate', | ||
LocationIndexCreateEvent::class => 'onLocationDocumentCreate', | ||
]; | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
code_samples/search/custom/src/EventSubscriber/CustomQueryFilterSubscriber.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\EventSubscriber; | ||
|
||
use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\LogicalAnd; | ||
use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\ObjectStateIdentifier; | ||
use Ibexa\Contracts\ElasticSearch\Query\Event\QueryFilterEvent; | ||
use Symfony\Component\EventDispatcher\EventSubscriberInterface; | ||
|
||
final class CustomQueryFilterSubscriber implements EventSubscriberInterface | ||
{ | ||
public function onQueryFilter(QueryFilterEvent $event): void | ||
{ | ||
$query = $event->getQuery(); | ||
|
||
$additionalCriteria = new ObjectStateIdentifier('locked'); | ||
|
||
if ($query->filter !== null) { | ||
$query->filter = $additionalCriteria; | ||
} else { | ||
// Append Criterion to existing filter | ||
$query->filter = new LogicalAnd([ | ||
$query->filter, | ||
$additionalCriteria, | ||
]); | ||
} | ||
} | ||
|
||
public static function getSubscribedEvents(): array | ||
{ | ||
return [ | ||
QueryFilterEvent::class => 'onQueryFilter', | ||
]; | ||
} | ||
} |
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
10 changes: 0 additions & 10 deletions
10
code_samples/search/elasticsearch/config/aggregation_services.yaml
This file was deleted.
Oops, something went wrong.
12 changes: 0 additions & 12 deletions
12
...les/search/elasticsearch/src/Query/Aggregation/Elasticsearch/PriorityRangeAggregation.php
This file was deleted.
Oops, something went wrong.
36 changes: 0 additions & 36 deletions
36
...es/search/elasticsearch/src/Query/Criterion/Elasticsearch/CameraManufacturerCriterion.php
This file was deleted.
Oops, something went wrong.
16 changes: 0 additions & 16 deletions
16
code_samples/search/elasticsearch/src/Query/SortClause/Elasticsearch/ScoreSortClause.php
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.