- 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
Example #1
0
 /**
  * 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]];
 }
Example #2
0
 /**
  * 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;
 }
Example #3
0
 /**
  * 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];
 }