/** * 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]]; }
/** * 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; }
/** * 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]; }