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 5 commits into
base: master
Choose a base branch
from
Draft

Enhance search customization #2591

wants to merge 5 commits into from

Conversation

adriendupuis
Copy link
Contributor

@adriendupuis adriendupuis commented Jan 11, 2025

Question Answer
JIRA Ticket N/A
Versions 4.6
Edition All
  • Merge ElasticSearch and Solr custom criterion, sort clause and aggregation
    Criteria, sort clauses and aggregations don't depend on the search engine, only their visitors and other handlers do.
  • Fix PriorityRangeAggregationResultExtractor class names.

Checklist

  • Text renders correctly
  • Text has been checked with vale
  • Description metadata is up to date
  • Redirects cover removed/moved pages
  • Code samples are working
  • PHP code samples have been fixed with PHP CS fixer
  • Added link to this PR in relevant JIRA ticket or code PR

adriendupuis and others added 5 commits January 11, 2025 12:35
Copy link

code_samples/ change report

Before (on target branch)After (in current PR)

code_samples/search/custom/config/aggregation_services.yaml


code_samples/search/custom/config/aggregation_services.yaml

docs/search/extensibility/create_custom_aggregation.md@47:    ``` yaml
docs/search/extensibility/create_custom_aggregation.md@48: services:
docs/search/extensibility/create_custom_aggregation.md@49: [[= include_file('code_samples/search/custom/config/aggregation_services.yaml', 1, 10) =]]
docs/search/extensibility/create_custom_aggregation.md@50: ```

001⫶ services:
002⫶ app.search.solr.query.aggregation_visitor.priority_range_aggregation:
003⫶ class: Ibexa\Solr\Query\Common\AggregationVisitor\PriorityRangeAggregationVisitor
004⫶ factory: [ '@Ibexa\Solr\Query\Common\AggregationVisitor\Factory\ContentFieldAggregationVisitorFactory', 'createRangeAggregationVisitor' ]
005⫶ arguments:
006⫶ $aggregationClass: 'App\Query\Aggregation\Solr\PriorityRangeAggregation'
007⫶ $searchIndexFieldName: 'priority_i'
008⫶ tags:
009⫶ - { name: ibexa.search.solr.query.content.aggregation.visitor }
010⫶ - { name: ibexa.search.solr.query.location.aggregation.visitor }

docs/search/extensibility/create_custom_aggregation.md@54: ``` yaml
docs/search/extensibility/create_custom_aggregation.md@55: services:
docs/search/extensibility/create_custom_aggregation.md@56: [[= include_file('code_samples/search/custom/config/aggregation_services.yaml', 11, 20) =]]
docs/search/extensibility/create_custom_aggregation.md@57: ```

001⫶ services:
002⫶ app.search.elasticsearch.query.aggregation_visitor.priority_range_aggregation:
003⫶ class: Ibexa\Elasticsearch\Query\AggregationVisitor\PriorityRangeAggregationVisitor
004⫶ factory: [ '@Ibexa\Elasticsearch\Query\AggregationVisitor\Factory\SearchFieldAggregationVisitorFactory', 'createRangeAggregationVisitor' ]
005⫶ arguments:
006⫶ $aggregationClass: 'App\Query\Aggregation\Elasticsearch\PriorityRangeAggregation'
007⫶ $searchIndexFieldName: 'priority_i'
008⫶ tags:
009⫶ - { name: ibexa.search.elasticsearch.query.location.aggregation.visitor }
010⫶ - { name: ibexa.search.elasticsearch.query.content.aggregation.visitor }

docs/search/extensibility/create_custom_aggregation.md@80: ``` yaml
docs/search/extensibility/create_custom_aggregation.md@81: services:
docs/search/extensibility/create_custom_aggregation.md@82: [[= include_file('code_samples/search/custom/config/aggregation_services.yaml', 21, 29) =]]
docs/search/extensibility/create_custom_aggregation.md@83: ```

001⫶ services:
002⫶ app.search.solr.query.aggregation_result_extractor.priority_range_aggregation:
003⫶ class: Ibexa\Solr\ResultExtractor\AggregationResultExtractor\RangeAggregationResultExtractor
004⫶ arguments:
005⫶ $aggregationClass: 'App\Query\Aggregation\Solr\PriorityRangeAggregation'
006⫶ $keyMapper: 'Ibexa\Solr\ResultExtractor\AggregationResultExtractor\RangeAggregationKeyMapper\IntRangeAggregationKeyMapper'
007⫶ tags:
008⫶ - { name: ibexa.search.solr.query.location.aggregation.result.extractor }
009⫶ - { name: ibexa.search.solr.query.content.aggregation.result.extractor }

docs/search/extensibility/create_custom_aggregation.md@90: ``` yaml
docs/search/extensibility/create_custom_aggregation.md@91: services:
docs/search/extensibility/create_custom_aggregation.md@92: [[= include_file('code_samples/search/custom/config/aggregation_services.yaml', 30, 37) =]]
docs/search/extensibility/create_custom_aggregation.md@93: ```

001⫶ services:
002⫶ app.search.elasticsearch.query.aggregation_result_extractor.priority_range_aggregation:
003⫶ class: Ibexa\Elasticsearch\Query\ResultExtractor\AggregationResultExtractor\RangeAggregationResultExtractor
004⫶ arguments:
005⫶ $aggregationClass: 'App\Query\Aggregation\Elasticsearch\PriorityRangeAggregation'
006⫶ tags:
007⫶ - { name: ibexa.search.elasticsearch.query.location.aggregation.result.extractor }
008⫶ - { name: ibexa.search.elasticsearch.query.content.aggregation.result.extractor }

docs/search/extensibility/create_custom_aggregation.md@179: ``` yaml
docs/search/extensibility/create_custom_aggregation.md@180: services:
docs/search/extensibility/create_custom_aggregation.md@181: [[= include_file('code_samples/search/custom/config/aggregation_services.yaml', 38, 47) =]]
docs/search/extensibility/create_custom_aggregation.md@182: ```

001⫶ services:
002⫶ App\Query\Aggregation\Solr\PriorityRangeAggregationVisitor:
003⫶ tags:
004⫶ - { name: ibexa.search.solr.query.location.aggregation.visitor }
005⫶ - { name: ibexa.search.solr.query.content.aggregation.visitor }
006⫶
007⫶ App\Query\Aggregation\Solr\PriorityRangeAggregationResultExtractor:
008⫶ tags:
009⫶ - { name: ibexa.search.solr.query.location.aggregation.result.extractor }
010⫶ - { name: ibexa.search.solr.query.content.aggregation.result.extractor }

docs/search/extensibility/create_custom_aggregation.md@190: ``` yaml
docs/search/extensibility/create_custom_aggregation.md@191: services:
docs/search/extensibility/create_custom_aggregation.md@192: [[= include_file('code_samples/search/custom/config/aggregation_services.yaml', 48, 57) =]]
docs/search/extensibility/create_custom_aggregation.md@193: ```

001⫶ services:
002⫶ App\Query\Aggregation\Elasticsearch\PriorityRangeAggregationVisitor:
003⫶ tags:
004⫶ - { name: ibexa.search.elasticsearch.query.location.aggregation.visitor }
005⫶ - { name: ibexa.search.elasticsearch.query.content.aggregation.visitor }
006⫶
007⫶ App\Query\Aggregation\Elasticsearch\PriorityRangeAggregationResultExtractor:
008⫶ tags:
009⫶ - { name: ibexa.search.elasticsearch.query.location.aggregation.result.extractor }
010⫶ - { name: ibexa.search.elasticsearch.query.content.aggregation.result.extractor }


code_samples/search/custom/config/criterion_services.yaml


code_samples/search/custom/config/criterion_services.yaml

docs/search/extensibility/create_custom_search_criterion.md@46:    ``` yaml
docs/search/extensibility/create_custom_search_criterion.md@47: services:
docs/search/extensibility/create_custom_search_criterion.md@48: [[= include_file('code_samples/search/custom/config/criterion_services.yaml', 1, 5) =]]
docs/search/extensibility/create_custom_search_criterion.md@49: ```


code_samples/search/elasticsearch/config/criterion_services.yaml
001⫶    services:
002⫶ App\Query\Criterion\Solr\CameraManufacturerVisitor:
003⫶ tags:
004⫶ - { name: ibexa.search.solr.query.content.criterion.visitor }
005⫶ - { name: ibexa.search.solr.query.location.criterion.visitor }


docs/search/extensibility/create_custom_search_criterion.md@64:    ``` yaml
docs/search/extensibility/create_custom_search_criterion.md@65: --8<--
docs/search/extensibility/create_custom_search_criterion.md@66: code_samples/search/elasticsearch/config/criterion_services.yaml
docs/search/extensibility/create_custom_search_criterion.md@67: --8<--
docs/search/extensibility/create_custom_search_criterion.md@68: ```
docs/search/extensibility/create_custom_search_criterion.md@53:    ``` yaml
docs/search/extensibility/create_custom_search_criterion.md@54: services:
docs/search/extensibility/create_custom_search_criterion.md@55: [[= include_file('code_samples/search/custom/config/criterion_services.yaml', 6, 10) =]]
docs/search/extensibility/create_custom_search_criterion.md@56: ```


001⫶services:
002⫶ App\Query\Criterion\Elasticsearch\CameraManufacturerVisitor:
001⫶    services:
002⫶ App\Query\Criterion\Elasticsearch\CameraManufacturerVisitor:
003⫶        tags:
004⫶ - { name: ibexa.search.elasticsearch.query.content.criterion.visitor }
005⫶ - { name: ibexa.search.elasticsearch.query.location.criterion.visitor }


003⫶        tags:
004⫶ - { name: ibexa.search.elasticsearch.query.content.criterion.visitor }
005⫶ - { name: ibexa.search.elasticsearch.query.location.criterion.visitor }


code_samples/search/custom/config/field_mapper_services.yaml
code_samples/search/elasticsearch/config/criterion_services.yaml




code_samples/search/solr/config/field_mapper_services.yaml
code_samples/search/custom/config/field_mapper_services.yaml

docs/search/extensibility/solr_document_field_mappers.md@65:``` yaml

docs/search/extensibility/solr_document_field_mappers.md@65:``` yaml
docs/search/extensibility/solr_document_field_mappers.md@66:[[= include_file('code_samples/search/solr/config/field_mapper_services.yaml') =]]
docs/search/extensibility/solr_document_field_mappers.md@66:[[= include_file('code_samples/search/custom/config/field_mapper_services.yaml') =]]
docs/search/extensibility/solr_document_field_mappers.md@67:```

001⫶services:
002⫶ App\Search\Mapper\WebinarEventTitleFulltextFieldMapper:
003⫶ arguments:
004⫶ - '@Ibexa\Contracts\Core\Persistence\Content\Handler'
005⫶ - '@Ibexa\Contracts\Core\Persistence\Content\Location\Handler'
006⫶ tags:
007⫶ - {name: ibexa.search.solr.field.mapper.content}


docs/search/extensibility/solr_document_field_mappers.md@67:```

001⫶services:
002⫶ App\Search\Mapper\WebinarEventTitleFulltextFieldMapper:
003⫶ arguments:
004⫶ - '@Ibexa\Contracts\Core\Persistence\Content\Handler'
005⫶ - '@Ibexa\Contracts\Core\Persistence\Content\Location\Handler'
006⫶ tags:
007⫶ - {name: ibexa.search.solr.field.mapper.content}


code_samples/search/custom/config/group_resolver_services.yaml
code_samples/search/solr/config/field_mapper_services.yaml




code_samples/search/elasticsearch/config/group_resolver_services.yaml
code_samples/search/custom/config/group_resolver_services.yaml

docs/search/extensibility/customize_elasticsearch_index_structure.md@52:``` yaml

docs/search/extensibility/customize_elasticsearch_index_structure.md@52:``` yaml
docs/search/extensibility/customize_elasticsearch_index_structure.md@53:[[= include_file('code_samples/search/elasticsearch/config/group_resolver_services.yaml') =]]
docs/search/extensibility/customize_elasticsearch_index_structure.md@53:[[= include_file('code_samples/search/custom/config/group_resolver_services.yaml') =]]
docs/search/extensibility/customize_elasticsearch_index_structure.md@54:```

001⫶services:
002⫶ App\GroupResolver\ContentTypeGroupGroupResolver:
003⫶ arguments:
004⫶ $contentTypeHandler: '@Ibexa\Contracts\Core\Persistence\Content\Type\Handler'


docs/search/extensibility/customize_elasticsearch_index_structure.md@54:```

001⫶services:
002⫶ App\GroupResolver\ContentTypeGroupGroupResolver:
003⫶ arguments:
004⫶ $contentTypeHandler: '@Ibexa\Contracts\Core\Persistence\Content\Type\Handler'


code_samples/search/custom/config/packages/elasticsearch-en.yaml
code_samples/search/elasticsearch/config/group_resolver_services.yaml




code_samples/search/elasticsearch/config/packages/elasticsearch-en.yaml
code_samples/search/custom/config/packages/elasticsearch-en.yaml

docs/search/search_engines/elastic_search/configure_elastic_search.md@494:```yaml hl_lines="3-5 15-23 35 41-52 94 99"

docs/search/search_engines/elastic_search/configure_elastic_search.md@494:```yaml hl_lines="3-5 15-23 35 41-52 94 99"
docs/search/search_engines/elastic_search/configure_elastic_search.md@495:[[= include_file('code_samples/search/elasticsearch/config/packages/elasticsearch-en.yaml') =]]
docs/search/search_engines/elastic_search/configure_elastic_search.md@495:[[= include_file('code_samples/search/custom/config/packages/elasticsearch-en.yaml') =]]
docs/search/search_engines/elastic_search/configure_elastic_search.md@496:```

001⫶ibexa_elasticsearch:
002⫶ index_templates:
003⫸ english:
004⫸ patterns:
005⫸ - '*_eng_gb*'
006⫶ settings:
007⫶ analysis:
008⫶ normalizer:
009⫶ lowercase_normalizer:
010⫶ type: custom
011⫶ char_filter: []
012⫶ filter:
013⫶ - lowercase
014⫶ analyzer:
015⫸ english_analyzer:
016⫸ type: custom
017⫸ tokenizer: lowercase
018⫸ filter:
019⫸ - lowercase
020⫸ - english_stop
021⫸ - english_keywords
022⫸ - english_stemmer
023⫸ - english_possessive_stemmer
024⫶ ibexa_spellcheck_analyzer:
025⫶ type: custom
026⫶ tokenizer: lowercase
027⫶ filter:
028⫶ - lowercase
029⫶ - ibexa_spellcheck_shingle_filter
030⫶ ibexa_spellcheck_raw_analyzer:
031⫶ type: custom
032⫶ tokenizer: standard
033⫶ filter:
034⫶ - lowercase
035⫸ - english_possessive_stemmer
036⫶ filter:
037⫶ ibexa_spellcheck_shingle_filter:
038⫶ type: shingle
039⫶ min_shingle_size: 2
040⫶ max_shingle_size: 3
041⫸ english_stop:
042⫸ type: stop
043⫸ stopwords: '_english_'
044⫸ english_keywords:
045⫸ type: keyword_marker
046⫸ keywords: []
047⫸ english_stemmer:
048⫸ type: stemmer
049⫸ language: light_english
050⫸ english_possessive_stemmer:
051⫸ type: stemmer
052⫸ language: possessive_english
053⫶ refresh_interval: "-1"
054⫶ mappings:
055⫶ dynamic_templates:
056⫶ - ez_int:
057⫶ match: "*_i"
058⫶ mapping:
059⫶ type: integer
060⫶ - ez_mint:
061⫶ match: "*_mi"
062⫶ mapping:
063⫶ type: integer
064⫶ - ez_id:
065⫶ match: "*_id"
066⫶ mapping:
067⫶ type: keyword
068⫶ - ez_mid:
069⫶ match: "*_mid"
070⫶ mapping:
071⫶ type: keyword
072⫶ - ez_string:
073⫶ match: "*_s"
074⫶ mapping:
075⫶ type: keyword
076⫶ normalizer: lowercase_normalizer
077⫶ - ez_mstring:
078⫶ match: "*_ms"
079⫶ mapping:
080⫶ type: keyword
081⫶ normalizer: lowercase_normalizer
082⫶ - ez_long:
083⫶ match: "*_l"
084⫶ mapping:
085⫶ type: long
086⫶ - ez_mlong:
087⫶ match: "*_ml"
088⫶ mapping:
089⫶ type: long
090⫶ - ez_text:
091⫶ match: "*_t"
092⫶ mapping:
093⫶ type: text
094⫸ analyzer: english_analyzer
095⫶ - ez_text_fulltext:
096⫶ match: "*_fulltext"
097⫶ mapping:
098⫶ type: text
099⫸ analyzer: english_analyzer
100⫶ - ez_boolean:
101⫶ match: "*_b"
102⫶ mapping:
103⫶ type: boolean
104⫶ - ez_mboolean:
105⫶ match: "*_mb"
106⫶ mapping:
107⫶ type: boolean
108⫶ - ez_float:
109⫶ match: "*_f"
110⫶ mapping:
111⫶ type: float
112⫶ - ez_double:
113⫶ match: "*_d"
114⫶ mapping:
115⫶ type: double
116⫶ - ez_date:
117⫶ match: "*_dt"
118⫶ mapping:
119⫶ type: date
120⫶ - ez_geolocation:
121⫶ match: "*_gl"
122⫶ mapping:
123⫶ type: geo_point
124⫶ - ez_spellcheck:
125⫶ match: "*_spellcheck"
126⫶ mapping:
127⫶ type: text
128⫶ analyzer: ibexa_spellcheck_analyzer
129⫶ fields:
130⫶ raw:
131⫶ type: text
132⫶ analyzer: ibexa_spellcheck_raw_analyzer


docs/search/search_engines/elastic_search/configure_elastic_search.md@496:```

001⫶ibexa_elasticsearch:
002⫶ index_templates:
003⫸ english:
004⫸ patterns:
005⫸ - '*_eng_gb*'
006⫶ settings:
007⫶ analysis:
008⫶ normalizer:
009⫶ lowercase_normalizer:
010⫶ type: custom
011⫶ char_filter: []
012⫶ filter:
013⫶ - lowercase
014⫶ analyzer:
015⫸ english_analyzer:
016⫸ type: custom
017⫸ tokenizer: lowercase
018⫸ filter:
019⫸ - lowercase
020⫸ - english_stop
021⫸ - english_keywords
022⫸ - english_stemmer
023⫸ - english_possessive_stemmer
024⫶ ibexa_spellcheck_analyzer:
025⫶ type: custom
026⫶ tokenizer: lowercase
027⫶ filter:
028⫶ - lowercase
029⫶ - ibexa_spellcheck_shingle_filter
030⫶ ibexa_spellcheck_raw_analyzer:
031⫶ type: custom
032⫶ tokenizer: standard
033⫶ filter:
034⫶ - lowercase
035⫸ - english_possessive_stemmer
036⫶ filter:
037⫶ ibexa_spellcheck_shingle_filter:
038⫶ type: shingle
039⫶ min_shingle_size: 2
040⫶ max_shingle_size: 3
041⫸ english_stop:
042⫸ type: stop
043⫸ stopwords: '_english_'
044⫸ english_keywords:
045⫸ type: keyword_marker
046⫸ keywords: []
047⫸ english_stemmer:
048⫸ type: stemmer
049⫸ language: light_english
050⫸ english_possessive_stemmer:
051⫸ type: stemmer
052⫸ language: possessive_english
053⫶ refresh_interval: "-1"
054⫶ mappings:
055⫶ dynamic_templates:
056⫶ - ez_int:
057⫶ match: "*_i"
058⫶ mapping:
059⫶ type: integer
060⫶ - ez_mint:
061⫶ match: "*_mi"
062⫶ mapping:
063⫶ type: integer
064⫶ - ez_id:
065⫶ match: "*_id"
066⫶ mapping:
067⫶ type: keyword
068⫶ - ez_mid:
069⫶ match: "*_mid"
070⫶ mapping:
071⫶ type: keyword
072⫶ - ez_string:
073⫶ match: "*_s"
074⫶ mapping:
075⫶ type: keyword
076⫶ normalizer: lowercase_normalizer
077⫶ - ez_mstring:
078⫶ match: "*_ms"
079⫶ mapping:
080⫶ type: keyword
081⫶ normalizer: lowercase_normalizer
082⫶ - ez_long:
083⫶ match: "*_l"
084⫶ mapping:
085⫶ type: long
086⫶ - ez_mlong:
087⫶ match: "*_ml"
088⫶ mapping:
089⫶ type: long
090⫶ - ez_text:
091⫶ match: "*_t"
092⫶ mapping:
093⫶ type: text
094⫸ analyzer: english_analyzer
095⫶ - ez_text_fulltext:
096⫶ match: "*_fulltext"
097⫶ mapping:
098⫶ type: text
099⫸ analyzer: english_analyzer
100⫶ - ez_boolean:
101⫶ match: "*_b"
102⫶ mapping:
103⫶ type: boolean
104⫶ - ez_mboolean:
105⫶ match: "*_mb"
106⫶ mapping:
107⫶ type: boolean
108⫶ - ez_float:
109⫶ match: "*_f"
110⫶ mapping:
111⫶ type: float
112⫶ - ez_double:
113⫶ match: "*_d"
114⫶ mapping:
115⫶ type: double
116⫶ - ez_date:
117⫶ match: "*_dt"
118⫶ mapping:
119⫶ type: date
120⫶ - ez_geolocation:
121⫶ match: "*_gl"
122⫶ mapping:
123⫶ type: geo_point
124⫶ - ez_spellcheck:
125⫶ match: "*_spellcheck"
126⫶ mapping:
127⫶ type: text
128⫶ analyzer: ibexa_spellcheck_analyzer
129⫶ fields:
130⫶ raw:
131⫶ type: text
132⫶ analyzer: ibexa_spellcheck_raw_analyzer


code_samples/search/custom/config/packages/elasticsearch.yaml
code_samples/search/elasticsearch/config/packages/elasticsearch-en.yaml




code_samples/search/elasticsearch/config/packages/elasticsearch.yaml
code_samples/search/custom/config/packages/elasticsearch.yaml

docs/search/extensibility/customize_elasticsearch_index_structure.md@60:``` yaml

docs/search/extensibility/customize_elasticsearch_index_structure.md@60:``` yaml
docs/search/extensibility/customize_elasticsearch_index_structure.md@61:[[= include_file('code_samples/search/elasticsearch/config/packages/elasticsearch.yaml') =]]
docs/search/extensibility/customize_elasticsearch_index_structure.md@61:[[= include_file('code_samples/search/custom/config/packages/elasticsearch.yaml') =]]
docs/search/extensibility/customize_elasticsearch_index_structure.md@62:```

001⫶ibexa_elasticsearch:
002⫶ document_group_resolver: 'App\GroupResolver\ContentTypeGroupGroupResolver'


docs/search/extensibility/customize_elasticsearch_index_structure.md@62:```

001⫶ibexa_elasticsearch:
002⫶ document_group_resolver: 'App\GroupResolver\ContentTypeGroupGroupResolver'


code_samples/search/elasticsearch/config/packages/elasticsearch.yaml


code_samples/search/custom/config/sort_clause_services.yaml

code_samples/search/custom/config/sort_clause_services.yaml

docs/search/extensibility/create_custom_sort_clause.md@50:    ``` yaml
docs/search/extensibility/create_custom_sort_clause.md@51: services:
docs/search/extensibility/create_custom_sort_clause.md@52: [[= include_file('code_samples/search/custom/config/sort_clause_services.yaml', 1, 5) =]]
docs/search/extensibility/create_custom_sort_clause.md@53: ```


code_samples/search/elasticsearch/config/sort_clause_services.yaml
001⫶    services:
002⫶ App\Query\SortClause\Solr\ScoreVisitor:
003⫶ tags:
004⫶ - { name: ibexa.search.solr.query.content.sort_clause.visitor }
005⫶ - { name: ibexa.search.solr.query.location.sort_clause.visitor }


docs/search/extensibility/create_custom_sort_clause.md@68:    ``` yaml
docs/search/extensibility/create_custom_sort_clause.md@69: --8<--
docs/search/extensibility/create_custom_sort_clause.md@70: code_samples/search/elasticsearch/config/sort_clause_services.yaml
docs/search/extensibility/create_custom_sort_clause.md@71: --8<--
docs/search/extensibility/create_custom_sort_clause.md@72: ```
docs/search/extensibility/create_custom_sort_clause.md@57:    ``` yaml
docs/search/extensibility/create_custom_sort_clause.md@58: services:
docs/search/extensibility/create_custom_sort_clause.md@59: [[= include_file('code_samples/search/custom/config/sort_clause_services.yaml', 6, 10) =]]
docs/search/extensibility/create_custom_sort_clause.md@60: ```


001⫶services:
002⫶ App\Query\SortClause\Elasticsearch\ScoreVisitor:
001⫶    services:
002⫶ App\Query\SortClause\Elasticsearch\ScoreVisitor:
003⫶        tags:
004⫶ - { name: ibexa.search.elasticsearch.query.content.sort_clause.visitor }
005⫶ - { name: ibexa.search.elasticsearch.query.location.sort_clause.visitor }


003⫶        tags:
004⫶ - { name: ibexa.search.elasticsearch.query.content.sort_clause.visitor }
005⫶ - { name: ibexa.search.elasticsearch.query.location.sort_clause.visitor }


code_samples/search/custom/src/GroupResolver/ContentTypeGroupGroupResolver.php
code_samples/search/elasticsearch/config/sort_clause_services.yaml




code_samples/search/elasticsearch/src/GroupResolver/ContentTypeGroupGroupResolver.php
code_samples/search/custom/src/GroupResolver/ContentTypeGroupGroupResolver.php

docs/search/extensibility/customize_elasticsearch_index_structure.md@46:``` php

docs/search/extensibility/customize_elasticsearch_index_structure.md@46:``` php
docs/search/extensibility/customize_elasticsearch_index_structure.md@47:[[= include_file('code_samples/search/elasticsearch/src/GroupResolver/ContentTypeGroupGroupResolver.php') =]]
docs/search/extensibility/customize_elasticsearch_index_structure.md@47:[[= include_file('code_samples/search/custom/src/GroupResolver/ContentTypeGroupGroupResolver.php') =]]
docs/search/extensibility/customize_elasticsearch_index_structure.md@48:```

001⫶<?php
002⫶
003⫶declare(strict_types=1);
004⫶
005⫶namespace App\GroupResolver;
006⫶
007⫶use Ibexa\Contracts\Core\Persistence\Content\Type\Handler;
008⫶use Ibexa\Contracts\Elasticsearch\ElasticSearch\Index\Group\GroupResolverInterface;
009⫶use Ibexa\Contracts\Elasticsearch\Mapping\BaseDocument;
010⫶
011⫶final class ContentTypeGroupGroupResolver implements GroupResolverInterface
012⫶{
013⫶ private Handler $contentTypeHandler;
014⫶
015⫶ public function __construct(Handler $contentTypeHandler)
016⫶ {
017⫶ $this->contentTypeHandler = $contentTypeHandler;
018⫶ }
019⫶
020⫶ public function resolveDocumentGroup(BaseDocument $document): string
021⫶ {
022⫶ $index = $this->contentTypeHandler->load($document->contentTypeId)->groupIds[0];
023⫶
024⫶ return (string)$index;
025⫶ }
026⫶}


docs/search/extensibility/customize_elasticsearch_index_structure.md@48:```

001⫶<?php
002⫶
003⫶declare(strict_types=1);
004⫶
005⫶namespace App\GroupResolver;
006⫶
007⫶use Ibexa\Contracts\Core\Persistence\Content\Type\Handler;
008⫶use Ibexa\Contracts\Elasticsearch\ElasticSearch\Index\Group\GroupResolverInterface;
009⫶use Ibexa\Contracts\Elasticsearch\Mapping\BaseDocument;
010⫶
011⫶final class ContentTypeGroupGroupResolver implements GroupResolverInterface
012⫶{
013⫶ private Handler $contentTypeHandler;
014⫶
015⫶ public function __construct(Handler $contentTypeHandler)
016⫶ {
017⫶ $this->contentTypeHandler = $contentTypeHandler;
018⫶ }
019⫶
020⫶ public function resolveDocumentGroup(BaseDocument $document): string
021⫶ {
022⫶ $index = $this->contentTypeHandler->load($document->contentTypeId)->groupIds[0];
023⫶
024⫶ return (string)$index;
025⫶ }
026⫶}


code_samples/search/custom/src/Query/Aggregation/Elasticsearch/PriorityRangeAggregationResultExtractor.php
code_samples/search/elasticsearch/src/GroupResolver/ContentTypeGroupGroupResolver.php




code_samples/search/elasticsearch/src/Query/Aggregation/Elasticsearch/PriorityAggregationResultExtractor.php
code_samples/search/custom/src/Query/Aggregation/Elasticsearch/PriorityRangeAggregationResultExtractor.php


docs/search/extensibility/create_custom_aggregation.md@195:    ``` php
docs/search/extensibility/create_custom_aggregation.md@196: --8<--
docs/search/extensibility/create_custom_aggregation.md@197: code_samples/search/elasticsearch/src/Query/Aggregation/Elasticsearch/PriorityAggregationResultExtractor.php
docs/search/extensibility/create_custom_aggregation.md@198: --8<--
docs/search/extensibility/create_custom_aggregation.md@199: ```
docs/search/extensibility/create_custom_aggregation.md@162:    ``` php
docs/search/extensibility/create_custom_aggregation.md@163: --8<--
docs/search/extensibility/create_custom_aggregation.md@164: code_samples/search/custom/src/Query/Aggregation/Elasticsearch/PriorityRangeAggregationResultExtractor.php
docs/search/extensibility/create_custom_aggregation.md@165: --8<--
docs/search/extensibility/create_custom_aggregation.md@166: ```

001⫶<?php
002⫶
003⫶declare(strict_types=1);
004⫶
005⫶namespace App\Query\Aggregation\Elasticsearch;
006⫶

001⫶<?php
002⫶
003⫶declare(strict_types=1);
004⫶
005⫶namespace App\Query\Aggregation\Elasticsearch;
006⫶
007⫶use Ibexa\Contracts\Core\Repository\Values\Content\Query\Aggregation;
008⫶use Ibexa\Contracts\Core\Repository\Values\Content\Search\AggregationResult;
009⫶use Ibexa\Contracts\Elasticsearch\Query\AggregationResultExtractor;
010⫶use Ibexa\Contracts\Elasticsearch\Query\LanguageFilter;
011⫶
012⫶final class PriorityAggregationResultExtractor implements AggregationResultExtractor
013⫶{
014⫶ public function supports(Aggregation $aggregation, LanguageFilter $languageFilter): bool
015⫶ {
016⫶ return $aggregation instanceof PriorityRangeAggregation;
017⫶ }
018⫶
019⫶ public function extract(Aggregation $aggregation, LanguageFilter $languageFilter, array $data): AggregationResult
020⫶ {
021⫶ $entries = [];
022⫶
023⫶ foreach ($data['buckets'] as $bucket) {
024⫶ $entries[] = new AggregationResult\RangeAggregationResultEntry(
025⫶ new Aggregation\Range($bucket['from'] ?? null, $bucket['to'] ?? null),
026⫶ $bucket['doc_count']
027⫶ );
028⫶ }
029⫶
030⫶ return new AggregationResult\RangeAggregationResult($aggregation->getName(), $entries);
031⫶ }
032⫶}
007⫶use App\Query\Aggregation\PriorityRangeAggregation;
008⫶use Ibexa\Contracts\Core\Repository\Values\Content\Query\Aggregation;
009⫶use Ibexa\Contracts\Core\Repository\Values\Content\Search\AggregationResult;
010⫶use Ibexa\Contracts\Elasticsearch\Query\AggregationResultExtractor;
011⫶use Ibexa\Contracts\Elasticsearch\Query\LanguageFilter;
012⫶
013⫶final class PriorityRangeAggregationResultExtractor implements AggregationResultExtractor
014⫶{
015⫶ public function supports(Aggregation $aggregation, LanguageFilter $languageFilter): bool
016⫶ {
017⫶ return $aggregation instanceof PriorityRangeAggregation;
018⫶ }
019⫶
020⫶ public function extract(Aggregation $aggregation, LanguageFilter $languageFilter, array $data): AggregationResult
021⫶ {
022⫶ $entries = [];
023⫶
024⫶ foreach ($data['buckets'] as $bucket) {
025⫶ $entries[] = new AggregationResult\RangeAggregationResultEntry(
026⫶ new Aggregation\Range($bucket['from'] ?? null, $bucket['to'] ?? null),
027⫶ $bucket['doc_count']
028⫶ );
029⫶ }
030⫶
031⫶ return new AggregationResult\RangeAggregationResult($aggregation->getName(), $entries);
032⫶ }
033⫶}




code_samples/search/custom/src/Query/Aggregation/Elasticsearch/PriorityRangeAggregationVisitor.php
code_samples/search/elasticsearch/src/Query/Aggregation/Elasticsearch/PriorityAggregationResultExtractor.php




code_samples/search/elasticsearch/src/Query/Aggregation/Elasticsearch/PriorityAggregationVisitor.php
code_samples/search/custom/src/Query/Aggregation/Elasticsearch/PriorityRangeAggregationVisitor.php


docs/search/extensibility/create_custom_aggregation.md@165:    ``` php
docs/search/extensibility/create_custom_aggregation.md@166: --8<--
docs/search/extensibility/create_custom_aggregation.md@167: code_samples/search/elasticsearch/src/Query/Aggregation/Elasticsearch/PriorityAggregationVisitor.php
docs/search/extensibility/create_custom_aggregation.md@168: --8<--
docs/search/extensibility/create_custom_aggregation.md@169: ```
docs/search/extensibility/create_custom_aggregation.md@132:    ``` php
docs/search/extensibility/create_custom_aggregation.md@133: --8<--
docs/search/extensibility/create_custom_aggregation.md@134: code_samples/search/custom/src/Query/Aggregation/Elasticsearch/PriorityRangeAggregationVisitor.php
docs/search/extensibility/create_custom_aggregation.md@135: --8<--
docs/search/extensibility/create_custom_aggregation.md@136: ```

001⫶<?php
002⫶
003⫶declare(strict_types=1);
004⫶
005⫶namespace App\Query\Aggregation\Elasticsearch;
006⫶

001⫶<?php
002⫶
003⫶declare(strict_types=1);
004⫶
005⫶namespace App\Query\Aggregation\Elasticsearch;
006⫶
007⫶use Ibexa\Contracts\Core\Repository\Values\Content\Query\Aggregation;
008⫶use Ibexa\Contracts\Elasticsearch\Query\AggregationVisitor;
009⫶use Ibexa\Contracts\Elasticsearch\Query\LanguageFilter;
010⫶
011⫶final class PriorityAggregationVisitor implements AggregationVisitor
012⫶{
013⫶ public function supports(Aggregation $aggregation, LanguageFilter $languageFilter): bool
014⫶ {
015⫶ return $aggregation instanceof PriorityRangeAggregation;
016⫶ }
017⫶
018⫶ /**
019⫶ * @param PriorityRangeAggregation $aggregation
020⫶ */
021⫶ public function visit(AggregationVisitor $dispatcher, Aggregation $aggregation, LanguageFilter $languageFilter): array
022⫶ {
023⫶ $ranges = [];
024⫶
025⫶ foreach ($aggregation->getRanges() as $range) {
026⫶ if ($range->getFrom() !== null && $range->getTo() !== null) {
027⫶ $ranges[] = [
028⫶ 'from' => $range->getFrom(),
029⫶ 'to' => $range->getTo(),
030⫶ ];
031⫶ } elseif ($range->getFrom() === null && $range->getTo() !== null) {
032⫶ $ranges[] = [
033⫶ 'to' => $range->getTo(),
034⫶ ];
035⫶ } elseif ($range->getFrom() !== null && $range->getTo() === null) {
036⫶ $ranges[] = [
037⫶ 'from' => $range->getFrom(),
038⫶ ];
039⫶ } else {
040⫶ // invalid range
041⫶ }
042⫶ }
043⫶
044⫶ return [
045⫶ 'range' => [
046⫶ 'field' => 'priority_i',
047⫶ 'ranges' => $ranges,
048⫶ ],
049⫶ ];
050⫶ }
051⫶}
007⫶use App\Query\Aggregation\PriorityRangeAggregation;
008⫶use Ibexa\Contracts\Core\Repository\Values\Content\Query\Aggregation;
009⫶use Ibexa\Contracts\Elasticsearch\Query\AggregationVisitor;
010⫶use Ibexa\Contracts\Elasticsearch\Query\LanguageFilter;
011⫶
012⫶final class PriorityRangeAggregationVisitor implements AggregationVisitor
013⫶{
014⫶ public function supports(Aggregation $aggregation, LanguageFilter $languageFilter): bool
015⫶ {
016⫶ return $aggregation instanceof PriorityRangeAggregation;
017⫶ }
018⫶
019⫶ /**
020⫶ * @param \App\Query\Aggregation\PriorityRangeAggregation $aggregation
021⫶ */
022⫶ public function visit(AggregationVisitor $dispatcher, Aggregation $aggregation, LanguageFilter $languageFilter): array
023⫶ {
024⫶ $ranges = [];
025⫶
026⫶ foreach ($aggregation->getRanges() as $range) {
027⫶ if ($range->getFrom() !== null && $range->getTo() !== null) {
028⫶ $ranges[] = [
029⫶ 'from' => $range->getFrom(),
030⫶ 'to' => $range->getTo(),
031⫶ ];
032⫶ } elseif ($range->getFrom() === null && $range->getTo() !== null) {
033⫶ $ranges[] = [
034⫶ 'to' => $range->getTo(),
035⫶ ];
036⫶ } elseif ($range->getFrom() !== null && $range->getTo() === null) {
037⫶ $ranges[] = [
038⫶ 'from' => $range->getFrom(),
039⫶ ];
040⫶ } else {
041⫶ // invalid range
042⫶ }
043⫶ }
044⫶
045⫶ return [
046⫶ 'range' => [
047⫶ 'field' => 'priority_i',
048⫶ 'ranges' => $ranges,
049⫶ ],
050⫶ ];
051⫶ }
052⫶}




code_samples/search/custom/src/Query/Aggregation/PriorityRangeAggregation.php
code_samples/search/elasticsearch/src/Query/Aggregation/Elasticsearch/PriorityAggregationVisitor.php




code_samples/search/solr/src/Query/Aggregation/Solr/PriorityRangeAggregation.php
code_samples/search/custom/src/Query/Aggregation/PriorityRangeAggregation.php


docs/search/extensibility/create_custom_aggregation.md@12:    ``` php
docs/search/extensibility/create_custom_aggregation.md@13: --8<--
docs/search/extensibility/create_custom_aggregation.md@14: code_samples/search/solr/src/Query/Aggregation/Solr/PriorityRangeAggregation.php
docs/search/extensibility/create_custom_aggregation.md@15: --8<--
docs/search/extensibility/create_custom_aggregation.md@16: ```
docs/search/extensibility/create_custom_aggregation.md@10:``` php
docs/search/extensibility/create_custom_aggregation.md@11:--8<--
docs/search/extensibility/create_custom_aggregation.md@12:code_samples/search/custom/src/Query/Aggregation/PriorityRangeAggregation.php
docs/search/extensibility/create_custom_aggregation.md@13:--8<--
docs/search/extensibility/create_custom_aggregation.md@14:```

001⫶<?php
002⫶
003⫶declare(strict_types=1);
004⫶

001⫶<?php
002⫶
003⫶declare(strict_types=1);
004⫶
005⫶namespace App\Query\Aggregation\Solr;
005⫶namespace App\Query\Aggregation;
006⫶
007⫶use Ibexa\Contracts\Core\Repository\Values\Content\Query\Aggregation\AbstractRangeAggregation;
008⫶use Ibexa\Contracts\Core\Repository\Values\Content\Query\Aggregation\LocationAggregation;
009⫶
010⫶final class PriorityRangeAggregation extends AbstractRangeAggregation implements LocationAggregation
011⫶{
012⫶}


006⫶
007⫶use Ibexa\Contracts\Core\Repository\Values\Content\Query\Aggregation\AbstractRangeAggregation;
008⫶use Ibexa\Contracts\Core\Repository\Values\Content\Query\Aggregation\LocationAggregation;
009⫶
010⫶final class PriorityRangeAggregation extends AbstractRangeAggregation implements LocationAggregation
011⫶{
012⫶}


code_samples/search/custom/src/Query/Aggregation/Solr/PriorityRangeAggregationResultExtractor.php
code_samples/search/solr/src/Query/Aggregation/Solr/PriorityRangeAggregation.php




code_samples/search/solr/src/Query/Aggregation/Solr/PriorityAggregationResultExtractor.php
code_samples/search/custom/src/Query/Aggregation/Solr/PriorityRangeAggregationResultExtractor.php


docs/search/extensibility/create_custom_aggregation.md@181:    ``` php
docs/search/extensibility/create_custom_aggregation.md@182: --8<--
docs/search/extensibility/create_custom_aggregation.md@183: code_samples/search/solr/src/Query/Aggregation/Solr/PriorityAggregationResultExtractor.php
docs/search/extensibility/create_custom_aggregation.md@184: --8<--
docs/search/extensibility/create_custom_aggregation.md@185: ```
docs/search/extensibility/create_custom_aggregation.md@148:    ``` php
docs/search/extensibility/create_custom_aggregation.md@149: --8<--
docs/search/extensibility/create_custom_aggregation.md@150: code_samples/search/custom/src/Query/Aggregation/Solr/PriorityRangeAggregationResultExtractor.php
docs/search/extensibility/create_custom_aggregation.md@151: --8<--
docs/search/extensibility/create_custom_aggregation.md@152: ```

001⫶<?php
002⫶
003⫶declare(strict_types=1);
004⫶
005⫶namespace App\Query\Aggregation\Solr;
006⫶

001⫶<?php
002⫶
003⫶declare(strict_types=1);
004⫶
005⫶namespace App\Query\Aggregation\Solr;
006⫶
007⫶use Ibexa\Contracts\Core\Repository\Values\Content\Query\Aggregation;
008⫶use Ibexa\Contracts\Core\Repository\Values\Content\Query\Aggregation\Range;
009⫶use Ibexa\Contracts\Core\Repository\Values\Content\Search\AggregationResult;
010⫶use Ibexa\Contracts\Core\Repository\Values\Content\Search\AggregationResult\RangeAggregationResult;
011⫶use Ibexa\Contracts\Core\Repository\Values\Content\Search\AggregationResult\RangeAggregationResultEntry;
012⫶use Ibexa\Contracts\Solr\ResultExtractor\AggregationResultExtractor;
013⫶use stdClass;
014⫶
015⫶final class PriorityAggregationResultExtractor implements AggregationResultExtractor
016⫶{
017⫶ public function canVisit(Aggregation $aggregation, array $languageFilter): bool
018⫶ {
019⫶ return $aggregation instanceof PriorityRangeAggregation;
020⫶ }
021⫶
022⫶ public function extract(Aggregation $aggregation, array $languageFilter, stdClass $data): AggregationResult
023⫶ {
024⫶ $entries = [];
025⫶ foreach ($data as $key => $bucket) {
026⫶ if ($key === 'count' || strpos($key, '_') === false) {
027⫶ continue;
028⫶ }
029⫶ [$from, $to] = explode('_', $key, 2);
030⫶ $entries[] = new RangeAggregationResultEntry(
031⫶ new Range(
032⫶ $from !== '*' ? $from : null,
033⫶ $to !== '*' ? $to : null
034⫶ ),
035⫶ $bucket->count
036⫶ );
037⫶ }
038⫶
039⫶ return new RangeAggregationResult($aggregation->getName(), $entries);
040⫶ }
041⫶}
007⫶use App\Query\Aggregation\PriorityRangeAggregation;
008⫶use Ibexa\Contracts\Core\Repository\Values\Content\Query\Aggregation;
009⫶use Ibexa\Contracts\Core\Repository\Values\Content\Query\Aggregation\Range;
010⫶use Ibexa\Contracts\Core\Repository\Values\Content\Search\AggregationResult;
011⫶use Ibexa\Contracts\Core\Repository\Values\Content\Search\AggregationResult\RangeAggregationResult;
012⫶use Ibexa\Contracts\Core\Repository\Values\Content\Search\AggregationResult\RangeAggregationResultEntry;
013⫶use Ibexa\Contracts\Solr\ResultExtractor\AggregationResultExtractor;
014⫶use stdClass;
015⫶
016⫶final class PriorityRangeAggregationResultExtractor implements AggregationResultExtractor
017⫶{
018⫶ public function canVisit(Aggregation $aggregation, array $languageFilter): bool
019⫶ {
020⫶ return $aggregation instanceof PriorityRangeAggregation;
021⫶ }
022⫶
023⫶ public function extract(Aggregation $aggregation, array $languageFilter, stdClass $data): AggregationResult
024⫶ {
025⫶ $entries = [];
026⫶ foreach ($...*[Comment body truncated]*

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant