Newer
Older
<?php
namespace IQDEV\ElasticSearch\Search\Aggs;
use IQDEV\ElasticSearch\Search\Nested;
final class AggsNumberFacet
{
public static function create(string $code, string $facet, string $path = 'search_data'): Aggs
{
$aggFacet = new Aggs($code);
$nested = new Nested();
$nested->setPath($path . '.' . $facet);
$aggFacet->setNested($nested);
$aggFacetCode = new Aggs("agg_{$facet}_code");
$aggFacetCode->setTerms(
(new Terms("{$path}.{$facet}.facet_code"))
);
$aggFacetValue = new Aggs("agg_{$facet}_value");