示例#1
0
 /**
  * Return field faceted data from faceted search result
  *
  * @param string $field
  * @return array
  */
 public function getFacetedData($field)
 {
     $this->_renderFilters();
     $aggregations = $this->queryResponse->getAggregations();
     $values = $aggregations->getBucket($field . '_bucket')->getValues();
     $result = [];
     foreach ($values as $value) {
         $metrics = $value->getMetrics();
         $result[$metrics['value']] = $metrics;
     }
     return $result;
 }
 /**
  * Return field faceted data from faceted search result
  *
  * @param string $field
  * @return array
  * @throws StateException
  */
 public function getFacetedData($field)
 {
     $this->_renderFilters();
     $result = [];
     $aggregations = $this->queryResponse->getAggregations();
     $bucket = $aggregations->getBucket($field . '_bucket');
     if ($bucket) {
         foreach ($bucket->getValues() as $value) {
             $metrics = $value->getMetrics();
             $result[$metrics['value']] = $metrics;
         }
     } else {
         throw new StateException(__('Bucket do not exists'));
     }
     return $result;
 }