Skip to content

Commit

Permalink
fixup! EZP-27458: Impl. Aggregation API
Browse files Browse the repository at this point in the history
  • Loading branch information
adamwojs committed Sep 30, 2020
1 parent 511e964 commit 28453ae
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion lib/Gateway/Native.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public function __construct(
*/
public function findContent(Query $query, array $languageSettings = [])
{
$parameters = $this->contentQueryConverter->convert($query);
$parameters = $this->contentQueryConverter->convert($query, $languageSettings);

return $this->internalFind($parameters, $languageSettings);
}
Expand Down
3 changes: 2 additions & 1 deletion lib/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,8 @@ public function findContent(Query $query, array $languageFilter = [])
return $this->contentResultExtractor->extract(
$this->gateway->findContent($query, $languageFilter),
$query->facetBuilders,
$query->aggregations
$query->aggregations,
$languageFilter
);
}

Expand Down
10 changes: 3 additions & 7 deletions lib/Query/Common/QueryConverter/NativeQueryConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
*/
namespace EzSystems\EzPlatformSolrSearchEngine\Query\Common\QueryConverter;

use eZ\Publish\API\Repository\Exceptions\NotImplementedException;
use eZ\Publish\API\Repository\Values\Content\Query;
use EzSystems\EzPlatformSolrSearchEngine\Query\AggregationVisitor;
use EzSystems\EzPlatformSolrSearchEngine\Query\QueryConverter;
Expand Down Expand Up @@ -68,7 +67,7 @@ public function __construct(
$this->aggregationVisitor = $aggregationVisitor;
}

public function convert(Query $query)
public function convert(Query $query, array $languageSettings = [])
{
$params = [
'q' => '{!lucene}' . $this->criterionVisitor->visit($query->query),
Expand All @@ -91,15 +90,12 @@ public function convert(Query $query)
$aggregations = [];

foreach ($query->aggregations as $aggregation) {
// TODO: Language filter argument is missing
try {
if ($this->aggregationVisitor->canVisit($aggregation, $languageSettings)) {
$aggregations[$aggregation->getName()] = $this->aggregationVisitor->visit(
$this->aggregationVisitor,
$aggregation,
[]
$languageSettings
);
} catch (NotImplementedException $e) {
// Ignore
}
}

Expand Down
5 changes: 4 additions & 1 deletion lib/Query/QueryConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ abstract class QueryConverter
/**
* Map query to a proper Solr representation.
*
* @param array $languageSettings - a map of filters for the returned fields.
* Currently supported: <code>array("languages" => array(<language1>,..))</code>.
*
* @return array
*/
abstract public function convert(Query $query);
abstract public function convert(Query $query, array $languageSettings = []);
}
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ services:
class: EzSystems\EzPlatformSolrSearchEngine\Query\Common\AggregationVisitor\RangeAggregationVisitor
factory: ['@EzSystems\EzPlatformSolrSearchEngine\Query\Common\AggregationVisitor\Factory\RawAggregationVisitorFactory', 'createRangeAggregationVisitor']
arguments:
$aggregationClass: 'eZ\Publish\API\Repository\Values\Content\Query\Aggregation\RawTermAggregation'
$aggregationClass: 'eZ\Publish\API\Repository\Values\Content\Query\Aggregation\RawRangeAggregation'
tags:
- { name: ezplatform.search.solr.query.content.aggregation_visitor }
- { name: ezplatform.search.solr.query.location.aggregation_visitor }
Expand Down
8 changes: 4 additions & 4 deletions lib/ResultExtractor.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
*/
namespace EzSystems\EzPlatformSolrSearchEngine;

use eZ\Publish\API\Repository\Values\Content\Query\AggregationInterface;
use eZ\Publish\API\Repository\Values\Content\Search\AggregationResultCollection;
use EzSystems\EzPlatformSolrSearchEngine\Gateway\EndpointRegistry;
use EzSystems\EzPlatformSolrSearchEngine\Query\FacetFieldVisitor;
Expand Down Expand Up @@ -48,11 +47,12 @@ public function __construct(
*
* @param mixed $data
* @param \eZ\Publish\API\Repository\Values\Content\Query\FacetBuilder[] $facetBuilders
* @param AggregationInterface[] $aggregations
* @param \eZ\Publish\API\Repository\Values\Content\Query\AggregationInterface[] $aggregations
* @param array $languageFilter
*
* @return \eZ\Publish\API\Repository\Values\Content\Search\SearchResult
*/
public function extract($data, array $facetBuilders = [], array $aggregations = [])
public function extract($data, array $facetBuilders = [], array $aggregations = [], array $languageFilter = [])
{
$result = new SearchResult(
[
Expand Down Expand Up @@ -97,7 +97,7 @@ public function extract($data, array $facetBuilders = [], array $aggregations =
if (isset($data->facets->{$name})) {
$aggregationsResults[] = $this->aggregationResultExtractor->extract(
$aggregation,
[],
$languageFilter,
$data->facets->{$name}
);
}
Expand Down

0 comments on commit 28453ae

Please sign in to comment.