Skip to content

Commit e162148

Browse files
committed
create_custom_aggregation.md: Narrow usage to location
priority_i is available only on locations *.query.content.* tags musn't be used with this example
1 parent 65ede71 commit e162148

File tree

2 files changed

+38
-23
lines changed

2 files changed

+38
-23
lines changed

code_samples/search/custom/config/aggregation_services.yaml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ services:
66
$aggregationClass: 'App\Query\Aggregation\Solr\PriorityRangeAggregation'
77
$searchIndexFieldName: 'priority_i'
88
tags:
9-
- { name: ibexa.search.solr.query.content.aggregation.visitor }
109
- { name: ibexa.search.solr.query.location.aggregation.visitor }
1110

1211
app.search.elasticsearch.query.aggregation_visitor.priority_range_aggregation:
@@ -17,7 +16,6 @@ services:
1716
$searchIndexFieldName: 'priority_i'
1817
tags:
1918
- { name: ibexa.search.elasticsearch.query.location.aggregation.visitor }
20-
- { name: ibexa.search.elasticsearch.query.content.aggregation.visitor }
2119

2220
app.search.solr.query.aggregation_result_extractor.priority_range_aggregation:
2321
class: Ibexa\Solr\ResultExtractor\AggregationResultExtractor\RangeAggregationResultExtractor
@@ -26,32 +24,26 @@ services:
2624
$keyMapper: 'Ibexa\Solr\ResultExtractor\AggregationResultExtractor\RangeAggregationKeyMapper\IntRangeAggregationKeyMapper'
2725
tags:
2826
- { name: ibexa.search.solr.query.location.aggregation.result.extractor }
29-
- { name: ibexa.search.solr.query.content.aggregation.result.extractor }
3027

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

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

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

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

5447
App\Query\Aggregation\Elasticsearch\PriorityRangeAggregationResultExtractor:
5548
tags:
5649
- { name: ibexa.search.elasticsearch.query.location.aggregation.result.extractor }
57-
- { name: ibexa.search.elasticsearch.query.content.aggregation.result.extractor }

docs/search/extensibility/create_custom_aggregation.md

Lines changed: 38 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,14 @@ The example below uses `RangeAggregationVisitor`:
4848

4949
``` yaml
5050
services:
51-
[[= include_file('code_samples/search/custom/config/aggregation_services.yaml', 1, 10) =]]
51+
[[= include_file('code_samples/search/custom/config/aggregation_services.yaml', 1, 9) =]]
5252
```
5353

5454
=== "Elasticsearch"
5555

5656
``` yaml
5757
services:
58-
[[= include_file('code_samples/search/custom/config/aggregation_services.yaml', 11, 20) =]]
58+
[[= include_file('code_samples/search/custom/config/aggregation_services.yaml', 10, 18) =]]
5959
```
6060

6161
The visitor is created by `SearchFieldAggregationVisitorFactory`.
@@ -76,22 +76,20 @@ For the result extractor, you can use the built-in `RangeAggregationResultExtrac
7676

7777
=== "Solr"
7878

79-
Tag the service with `ibexa.search.solr.query.location.aggregation.result.extractor`
80-
and `ibexa.search.solr.query.content.aggregation.result.extractor`.
79+
Tag the service with `ibexa.search.solr.query.location.aggregation.result.extractor`.
8180

8281
``` yaml
8382
services:
84-
[[= include_file('code_samples/search/custom/config/aggregation_services.yaml', 21, 29) =]]
83+
[[= include_file('code_samples/search/custom/config/aggregation_services.yaml', 19, 26) =]]
8584
```
8685

8786
=== "Elasticsearch"
8887

89-
Tag the service with `ibexa.search.elasticsearch.query.location.aggregation.result.extractor`
90-
and `ibexa.search.elasticsearch.query.content.aggregation.result.extractor`.
88+
Tag the service with `ibexa.search.elasticsearch.query.location.aggregation.result.extractor`.
9189

9290
``` yaml
9391
services:
94-
[[= include_file('code_samples/search/custom/config/aggregation_services.yaml', 30, 37) =]]
92+
[[= include_file('code_samples/search/custom/config/aggregation_services.yaml', 27, 33) =]]
9593
```
9694

9795
You can use a different type of aggregation, followed by respective visitor and extractor classes:
@@ -141,6 +139,31 @@ The `canVisit()` method checks whether the provided aggregation is of the suppor
141139

142140
The `visit()` method returns an array of results.
143141

142+
Finally, register the aggregation visitor as a service.
143+
144+
=== "Solr"
145+
146+
Tag the aggregation visitor with `ibexa.search.solr.query.location.aggregation.visitor`:
147+
148+
``` yaml
149+
services:
150+
[[= include_file('code_samples/search/custom/config/aggregation_services.yaml', 34, 37) =]]
151+
```
152+
153+
For content-based aggregations, use the `ibexa.search.solr.query.content.aggregation.visitor` tag.
154+
155+
=== "Elasticsearch"
156+
157+
Tag the aggregation visitor with `ibexa.elasticsearch.query.location.aggregation_visitor`:
158+
159+
``` yaml
160+
services:
161+
[[= include_file('code_samples/search/custom/config/aggregation_services.yaml', 42, 45) =]]
162+
```
163+
164+
For content-based aggregations, use the `ibexa.search.elasticsearch.query.content.aggregation.visitor` tag.
165+
166+
144167
### Create result extractor
145168

146169
=== "Solr"
@@ -172,26 +195,26 @@ The `visit()` method returns an array of results.
172195
The `extract()` method converts the [raw data provided by the search engine](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations.html) to a `RangeAggregationResult` object.
173196

174197

175-
Finally, register both the aggregation visitor and the result extractor as services.
198+
Finally, register the result extractor as a service.
176199

177200
=== "Solr"
178201

179-
Tag the aggregation visitor with `ibexa.search.solr.query.location.aggregation.visitor` and the result extractor with `ibexa.search.solr.query.location.aggregation.result.extractor`:
202+
Tag the result extractor with `ibexa.search.solr.query.location.aggregation.result.extractor`:
180203

181204
``` yaml
182205
services:
183-
[[= include_file('code_samples/search/custom/config/aggregation_services.yaml', 38, 47) =]]
206+
[[= include_file('code_samples/search/custom/config/aggregation_services.yaml', 38, 41) =]]
184207
```
185208

186-
For content-based aggregations, use the `ibexa.search.solr.query.content.aggregation.visitor` and `ibexa.search.solr.query.content.aggregation.result.extractor` tags respectively.
209+
For content-based aggregations, use the `ibexa.search.solr.query.content.aggregation.result.extractor` tag.
187210

188211
=== "Elasticsearch"
189212

190-
Tag the aggregation visitor with `ibexa.elasticsearch.query.location.aggregation_visitor` and the result extractor with `ibexa.elasticsearch.query.location.aggregation_result_extractor`:
213+
Tag the result extractor with `ibexa.elasticsearch.query.location.aggregation_result_extractor`:
191214

192215
``` yaml
193216
services:
194-
[[= include_file('code_samples/search/custom/config/aggregation_services.yaml', 48, 57) =]]
217+
[[= include_file('code_samples/search/custom/config/aggregation_services.yaml', 46, 49) =]]
195218
```
196219

197-
For content-based aggregations, use the `ibexa.search.elasticsearch.query.content.aggregation.visitor` and `ibexa.search.elasticsearch.query.content.aggregation.result.extractor` tags respectively.
220+
For content-based aggregations, use the `ibexa.search.elasticsearch.query.content.aggregation.result.extractor` tag.

0 commit comments

Comments
 (0)