- Define new usable bucket types in ElasticSuite (histogrrams) - Additional methods to handle nested and filtered aggregations
Author: Aurelien FOUCRET (aurelien.foucret@smile.fr)
Inheritance: extends Magento\Framework\Search\Request\BucketInterface
コード例 #1
0
ファイル: QueryGroup.php プロジェクト: smile-sa/elasticsuite
 /**
  * Build the aggregation.
  *
  * @param BucketInterface $bucket Term bucket.
  *
  * @return array
  */
 public function buildBucket(BucketInterface $bucket)
 {
     $filters = [];
     foreach ($bucket->getQueries() as $value => $query) {
         $filters[$value] = $this->queryBuilder->buildQuery($query);
     }
     return ['filters' => ['filters' => $filters]];
 }
コード例 #2
0
ファイル: Term.php プロジェクト: smile-sa/elasticsuite
 /**
  * Build the aggregation.
  *
  * @param BucketInterface $bucket Term bucket.
  *
  * @return array
  */
 public function buildBucket(BucketInterface $bucket)
 {
     $aggregation = ['terms' => ['field' => $bucket->getField(), 'size' => $bucket->getSize()]];
     if (in_array($bucket->getSortOrder(), [$bucket::SORT_ORDER_COUNT, $bucket::SORT_ORDER_MANUAL])) {
         $aggregation['terms']['order'] = [$bucket::SORT_ORDER_COUNT => SortOrderInterface::SORT_DESC];
     } elseif ($bucket->getSortOrder() == $bucket::SORT_ORDER_TERM) {
         $aggregation['terms']['order'] = [$bucket::SORT_ORDER_TERM => SortOrderInterface::SORT_ASC];
     } elseif ($bucket->getSortOrder() == $bucket::SORT_ORDER_RELEVANCE && !$bucket->isNested()) {
         $aggregation['aggregations']['termRelevance'] = ['avg' => ['script' => $bucket::SORT_ORDER_RELEVANCE]];
         $aggregation['terms']['order'] = ['termRelevance' => SortOrderInterface::SORT_DESC];
     }
     return $aggregation;
 }
コード例 #3
0
ファイル: Histogram.php プロジェクト: smile-sa/elasticsuite
 /**
  * Build the aggregation.
  *
  * @param BucketInterface $bucket Histogram bucket.
  *
  * @return array
  */
 public function buildBucket(BucketInterface $bucket)
 {
     $aggParams = ['field' => $bucket->getField(), 'interval' => $bucket->getInterval(), 'min_doc_count' => $bucket->getMinDocCount()];
     return ['histogram' => $aggParams];
 }