Skip to content
Merged
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
43 changes: 0 additions & 43 deletions docs/api/public_php_api_search.md
Original file line number Diff line number Diff line change
Expand Up @@ -406,46 +406,3 @@ $query->aggregations[] = new IntegerRangeAggregation('range', 'person', 'age',
In the example all values above (and including) 60 are included in the last range.

See [Agrregation reference](../guide/search/aggregation_reference.md) for details of all available aggregations.

## Faceted search

!!! caution "Deprecated"

Search Facets are deprecated since version v3.2.

Use [Aggregation API](#aggregation) instead.

!!! tip "Checking feature support per search engine"

Faceted search is available only for the Solr search engine.

To find out if a given search engine supports any of the advanced search capabilities,
use the [`Ibexa\Contracts\Core\Repository\SearchService::supports`](https://github.com/ibexa/core/blob/main/src/contracts/Repository/SearchService.php#L188-L199) method:

``` php
$facetSupport = $this->searchService->supports(SearchService::CAPABILITY_FACETS);
```

Faceted search enables you to find the count of search results for each Facet value.

To do this, you need to make use of the query's `$facetBuilders` property:

``` php
$query->facetBuilders[] = new FacetBuilderUserFacetBuilder(
[
'name' => 'User',
'type' => FacetBuilder\UserFacetBuilder::OWNER,
'minCount' => 2,
'limit' => 5
]
);

$result = $this->searchService->findContentInfo($query);

$output->writeln("Number of results per facet value: ");
foreach ($result->facets[0]->entries as $facetEntry) {
$output->writeln("* " . $facetEntry);
}
```

See [Search Facet reference](../guide/search/search.md#search-facet-reference) for details of all available Facets.
2 changes: 1 addition & 1 deletion docs/guide/persistence_cache.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Notes:
order to allow clearing cache by alternative indexes.
For instance tree operations or changes to Content Types are
examples of operations that also need to invalidate content cache by tags.
- Search is not defined as persistence and the queries themselves are not planned to be cached as they are too complex by design (full text, facets, etc.).
- Search is not defined as persistence and the queries themselves are not planned to be cached as they are too complex by design (for example, full text).
Use [Solr](search/solr.md) which caches this for you to improve scale/performance, and to offload your database.

For further details on which calls are cached or not, see details in the [Symfony Web Debug Toolbar](devops.md#web-debug-toolbar)
Expand Down
2 changes: 1 addition & 1 deletion docs/guide/search/elastic.md
Original file line number Diff line number Diff line change
Expand Up @@ -588,5 +588,5 @@ For more information about how Elasticsearch handles settings and mappings from

## Extending Elasticsearch

To learn how to create custom Search Criteria, Sort Clauses and Facets for use with Elasticsearch,
To learn how to create custom Search Criteria and Sort Clauses for use with Elasticsearch,
and how to index custom data and manipulate the query, see [Elasticsearch extensibility](extend_elasticsearch.md).
134 changes: 0 additions & 134 deletions docs/guide/search/extend_elasticsearch.md
Original file line number Diff line number Diff line change
Expand Up @@ -519,137 +519,3 @@ services:
```

For content-based aggregations, use the `ibexa.elasticsearch.query.content.aggregation_visitor.` and `ibexa.elasticsearch.query.content.aggregation_result_extractor` tags respectively.

## Custom Facet

!!! caution "Deprecated"

Search Facets are deprecated since version v3.2. Use a custom [Aggregation](../../api/public_php_api_search.md#aggregation) instead.

To create a custom search Facet for use with Elasticsearch, create a Facet class and a Facet builder.
You also need to add a visitor and a result extractor.

The following example shows how to create a Facet that filters results according to their Content Type group.

`src/Query/ContentTypeGroupFacet`:

``` php
<?php

declare(strict_types=1);

namespace App\Query\Facet;

use Ibexa\Contracts\Core\Repository\Values\Content\Search\Facet;

/**
* This class holds counts of content with content type.
*/
final class ContentTypeGroupFacet extends Facet
{
/**
* An array with ContentTypeGroup::$id as key and count of matching content objects as value.
*
* @var int[]
*/
public $entries = [];
}
```

`src/Query/ContentTypeGroupFacetBuilder`:

``` php
<?php

declare(strict_types=1);

namespace App\Query\FacetBuilder;

use Ibexa\Contracts\Core\Repository\Values\Content\Query\FacetBuilder;

final class ContentTypeGroupFacetBuilder extends FacetBuilder
{
}
```

`src/Query/ContentTypeGroupFacetBuilderVisitor`:

``` php
<?php

declare(strict_types=1);

namespace App\Query\FacetBuilder;

use Ibexa\Contracts\Core\Repository\Values\Content\Query\FacetBuilder;
use Ibexa\Contracts\ElasticSearchEngine\Query\FacetBuilderVisitor;
use Ibexa\Contracts\ElasticSearchEngine\Query\LanguageFilter;

/**
* Example (simplified) visitor implementation for ContentTypeGroupFacetBuilder
*/
final class ContentTypeGroupFacetBuilderVisitor implements FacetBuilderVisitor
{
public function supports(FacetBuilder $builder, LanguageFilter $languageFilter): bool
{
return $builder instanceof ContentTypeGroupFacetBuilder;
}

public function visit(FacetBuilderVisitor $dispatcher, FacetBuilder $builder, LanguageFilter $languageFilter): array
{
return [
'terms' => [
'field' => 'content_type_group_id_mid',
],
];
}
}
```

`src/Query/ContentTypeGroupFacetResultExtractor`:

``` php
<?php

declare(strict_types=1);

namespace App\Query\FacetBuilder;

use App\Query\Facet\ContentTypeGroupFacet;
use Ibexa\Contracts\Core\Repository\Values\Content\Query\FacetBuilder;
use Ibexa\Contracts\Core\Repository\Values\Content\Search\Facet;
use Ibexa\Contracts\ElasticSearchEngine\Query\FacetResultExtractor;

final class ContentTypeGroupFacetResultExtractor implements FacetResultExtractor
{
public function supports(FacetBuilder $builder): bool
{
return $builder instanceof ContentTypeGroupFacetBuilder;
}

public function extract(FacetBuilder $builder, array $data): Facet
{
$facet = new ContentTypeGroupFacet();
$facet->name = $builder->name;
foreach ($data['buckets'] as $bucket) {
$facet->entries[$bucket['key']] = $bucket['doc_count'];
}

return $facet;
}
}
```

Remember to register the facet classes as services:

``` yaml
services:
App\Query\FacetBuilder\ContentTypeGroupFacetBuilderVisitor:
tags:
- { name: ibexa.elasticsearch.query.content.facet_builder_visitor }
- { name: ibexa.elasticsearch.query.location.facet_builder_visitor }

App\Query\FacetBuilder\ContentTypeGroupFacetResultExtractor:
tags:
- { name: ibexa.search.elasticsearch.query.facet_result.extractor }
```
38 changes: 0 additions & 38 deletions docs/guide/search/search.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,44 +42,6 @@ which will be used to translate the value object into a storage-specific search
As an example take a look at the [`ContentId` Criterion handler](https://github.com/ibexa/core/blob/main/src/lib/Search/Legacy/Content/Common/Gateway/CriterionHandler/ContentId.php) in Legacy search engine
or [`ContentId` Criterion handler](https://github.com/ibexa/solr-search-engine/blob/main/lib/Query/Common/CriterionVisitor/ContentIdIn.php) in Solr search engine.

## Search Facet reference

!!! caution "Deprecated"

Search Facets are deprecated since version v3.2.

Use [Aggregation API](../../api/public_php_api_search.md#aggregation) instead.

Search Facets enable you to apply [faceted search](../../api/public_php_api_search.md#faceted-search)
to get a count of search results for each Facet value.

### Available FacetBuilders

#### ContentTypeFacetBuilder

Arguments:

- `name`: `string`
- `minCount` (optional): `integer`
- `limit` (optional): `integer`

#### SectionFacetBuilder

Arguments:

- `name`: `string`
- `minCount` (optional): `integer`
- `limit` (optional): `integer`

#### UserFacetBuilder

Arguments:

- `name`: `string`
- `type`: `string` [`OWNER = 'owner'`, `GROUP = 'group'`, `MODIFIER = 'modifier'`]
- `minCount` (optional): `integer`
- `limit` (optional): `integer`

## Custom Criteria and Sort Clauses

Sometimes you will find that standard Search Criteria and Sort Clauses provided with [[= product_name =]] are not sufficient for your needs. Most often this will be the case if you have a custom Field Type using external storage which cannot be searched using the standard Field Criterion.
Expand Down