commit
a830a9b7b6
|
@ -39,6 +39,18 @@ class FantaPaginatorAdapter implements AdapterInterface
|
|||
{
|
||||
return $this->adapter->getFacets();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns Aggregations
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function getAggregations()
|
||||
{
|
||||
return $this->adapter->getAggregations();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a slice of the results.
|
||||
|
|
|
@ -31,4 +31,11 @@ interface PaginatorAdapterInterface
|
|||
* @return mixed
|
||||
*/
|
||||
function getFacets();
|
||||
|
||||
/**
|
||||
* Returns Aggregations
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
function getAggregations();
|
||||
}
|
||||
|
|
|
@ -28,4 +28,11 @@ interface PartialResultsInterface
|
|||
* @return array
|
||||
*/
|
||||
function getFacets();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the aggregations
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function getAggregations();
|
||||
}
|
||||
|
|
|
@ -36,6 +36,11 @@ class RawPaginatorAdapter implements PaginatorAdapterInterface
|
|||
* @var array for the facets
|
||||
*/
|
||||
private $facets;
|
||||
|
||||
/**
|
||||
* @var array for the aggregations
|
||||
*/
|
||||
private $aggregations;
|
||||
|
||||
/**
|
||||
* @see PaginatorAdapterInterface::__construct
|
||||
|
@ -82,6 +87,7 @@ class RawPaginatorAdapter implements PaginatorAdapterInterface
|
|||
$resultSet = $this->searchable->search($query, $this->options);
|
||||
$this->totalHits = $resultSet->getTotalHits();
|
||||
$this->facets = $resultSet->getFacets();
|
||||
$this->aggregations = $resultSet->getAggregations();
|
||||
return $resultSet;
|
||||
}
|
||||
|
||||
|
@ -129,6 +135,19 @@ class RawPaginatorAdapter implements PaginatorAdapterInterface
|
|||
|
||||
return $this->facets;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns Aggregations
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getAggregations() {
|
||||
if (!isset($this->aggregations)) {
|
||||
$this->aggregations = $this->searchable->search($this->query)->getAggregations();
|
||||
}
|
||||
|
||||
return $this->aggregations;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Query
|
||||
|
|
|
@ -49,4 +49,16 @@ class RawPartialResults implements PartialResultsInterface
|
|||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getAggregations()
|
||||
{
|
||||
if ($this->resultSet->hasAggregations()) {
|
||||
return $this->resultSet->getAggregations();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,6 +32,10 @@ class PaginateElasticaQuerySubscriber implements EventSubscriberInterface
|
|||
if (null != $facets) {
|
||||
$event->setCustomPaginationParameter('facets', $facets);
|
||||
}
|
||||
$aggregations = $results->getAggregations();
|
||||
if (null != $aggregations) {
|
||||
$event->setCustomPaginationParameter('aggregations', $aggregations);
|
||||
}
|
||||
|
||||
$event->stopPropagation();
|
||||
}
|
||||
|
@ -73,4 +77,4 @@ class PaginateElasticaQuerySubscriber implements EventSubscriberInterface
|
|||
'knp_pager.items' => array('items', 1)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue