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

EZP-27458: Aggregation API #192

Merged
merged 1 commit into from
Oct 6, 2020
Merged

EZP-27458: Aggregation API #192

merged 1 commit into from
Oct 6, 2020

Conversation

adamwojs
Copy link
Member

@adamwojs adamwojs commented Aug 19, 2020

Description

Implementation of Aggregation API (see ezsystems/ezplatform-kernel#94) for Solr Search Engine.  

Sequence diagram

Extension points

The following extension points has been introduced in order to be able to handle custom aggregations. 

EzSystems\EzPlatformSolrSearchEngine\Query\AggregationVisitor

AggregationVisitor is responsible for building aggregation query base on aggregation definition.

<?php

namespace EzSystems\EzPlatformSolrSearchEngine\Query;

use eZ\Publish\API\Repository\Values\Content\Query\AggregationInterface;

interface AggregationVisitor
{
    /**
     * Check if visitor is applicable to current aggreagtion.
     */
    public function canVisit(AggregationInterface $aggregation, array $languageFilter): bool;

    /**
     * @return string[]
     */
    public function visit(
        AggregationVisitor $dispatcherVisitor,
        AggregationInterface $aggregation,
        array $languageFilter
    ): array;
} 

EzSystems\EzPlatformSolrSearchEngine\Query\AggregationVisitor::visit result will be encoded as JSON and should be compatible with JSON Facet API described here: https://lucene.apache.org/solr/guide/7_7/json-facet-api.html. 

AggregationVisitor implementations should be registered as a service and tagged with ezplatform.search.solr.query.content.aggregation_visitor and/or ezplatform.search.solr.query.location.aggregation_visitor tag.

EzSystems\EzPlatformSolrSearchEngine\ResultExtractor\AggregationResultExtractor

AggregationResultExtractor is responsible for transforming raw aggregation results into AggregationResult object. 

<?php

namespace EzSystems\EzPlatformSolrSearchEngine\ResultExtractor;

use eZ\Publish\API\Repository\Values\Content\Query\AggregationInterface;
use eZ\Publish\API\Repository\Values\Content\Search\AggregationResult;
use stdClass;

interface AggregationResultExtractor
{
    public function canVisit(AggregationInterface $aggregation, array $languageFilter): bool;

    public function extract(AggregationInterface $aggregation, array $languageFilter, stdClass $data): AggregationResult;
} 

AggregationResultExtractor implementations should be registered as a service and tagged with ezplatform.search.solr.query.content.aggregation_result_extractor and/or ezplatform.search.solr.query.location.aggregation_result_extractor tag. 

Deprecations

The following classes/interfaces has been deprecated:

  • \EzSystems\EzPlatformSolrSearchEngine\Query\FacetFieldVisitor
  • \EzSystems\EzPlatformSolrSearchEngine\Query\FacetBuilderVisitor and all inheriting classes

as well as the following services/aliases:

  • ezpublish.search.solr.result_extractor.native
  • ezpublish.search.solr.result_extractor

BC Breaks

  • Added $languageSettings parameter to EzSystems\EzPlatformSolrSearchEngine\Query\QueryConverter::convert
  • Added $languageFilter and $aggregations parameters to EzSystems\EzPlatformSolrSearchEngine\ResultExtractor::extract

Links

Checklist

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

Successfully merging this pull request may close these issues.

2 participants