| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536 |
- <?php
- namespace Elastica\QueryBuilder\DSL;
- use Elastica\Aggregation\Avg;
- use Elastica\Aggregation\AvgBucket;
- use Elastica\Aggregation\BucketScript;
- use Elastica\Aggregation\Cardinality;
- use Elastica\Aggregation\DateHistogram;
- use Elastica\Aggregation\DateRange;
- use Elastica\Aggregation\ExtendedStats;
- use Elastica\Aggregation\Filter as FilterAggregation;
- use Elastica\Aggregation\Filters;
- use Elastica\Aggregation\GeoDistance;
- use Elastica\Aggregation\GeohashGrid;
- use Elastica\Aggregation\GlobalAggregation;
- use Elastica\Aggregation\Histogram;
- use Elastica\Aggregation\IpRange;
- use Elastica\Aggregation\Max;
- use Elastica\Aggregation\Min;
- use Elastica\Aggregation\Missing;
- use Elastica\Aggregation\Nested;
- use Elastica\Aggregation\Percentiles;
- use Elastica\Aggregation\Range;
- use Elastica\Aggregation\ReverseNested;
- use Elastica\Aggregation\ScriptedMetric;
- use Elastica\Aggregation\SerialDiff;
- use Elastica\Aggregation\SignificantTerms;
- use Elastica\Aggregation\Stats;
- use Elastica\Aggregation\Sum;
- use Elastica\Aggregation\SumBucket;
- use Elastica\Aggregation\Terms;
- use Elastica\Aggregation\TopHits;
- use Elastica\Aggregation\ValueCount;
- use Elastica\Exception\NotImplementedException;
- use Elastica\Query\AbstractQuery;
- use Elastica\QueryBuilder\DSL;
- /**
- * elasticsearch aggregation DSL.
- *
- * @author Manuel Andreo Garcia <andreo.garcia@googlemail.com>
- *
- * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations.html
- */
- class Aggregation implements DSL
- {
- /**
- * must return type for QueryBuilder usage.
- *
- * @return string
- */
- public function getType()
- {
- return DSL::TYPE_AGGREGATION;
- }
- /**
- * min aggregation.
- *
- * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-min-aggregation.html
- *
- * @param string $name
- *
- * @return Min
- */
- public function min($name)
- {
- return new Min($name);
- }
- /**
- * max aggregation.
- *
- * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-max-aggregation.html
- *
- * @param string $name
- *
- * @return Max
- */
- public function max($name)
- {
- return new Max($name);
- }
- /**
- * sum aggregation.
- *
- * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-sum-aggregation.html
- *
- * @param string $name
- *
- * @return Sum
- */
- public function sum($name)
- {
- return new Sum($name);
- }
- /**
- * sum bucket aggregation.
- *
- * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-pipeline-sum-bucket-aggregation.html
- *
- * @param string $name
- * @param string|null $bucketsPath
- *
- * @return SumBucket
- */
- public function sum_bucket($name, $bucketsPath = null)
- {
- return new SumBucket($name, $bucketsPath);
- }
- /**
- * avg aggregation.
- *
- * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-avg-aggregation.html
- *
- * @param string $name
- *
- * @return Avg
- */
- public function avg($name)
- {
- return new Avg($name);
- }
- /**
- * avg bucket aggregation.
- *
- * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-pipeline-avg-bucket-aggregation.html
- *
- * @param string $name
- * @param string|null $bucketsPath
- *
- * @return AvgBucket
- */
- public function avg_bucket($name, $bucketsPath = null)
- {
- return new AvgBucket($name, $bucketsPath);
- }
- /**
- * stats aggregation.
- *
- * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-stats-aggregation.html
- *
- * @param string $name
- *
- * @return Stats
- */
- public function stats($name)
- {
- return new Stats($name);
- }
- /**
- * extended stats aggregation.
- *
- * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-extendedstats-aggregation.html
- *
- * @param string $name
- *
- * @return ExtendedStats
- */
- public function extended_stats($name)
- {
- return new ExtendedStats($name);
- }
- /**
- * value count aggregation.
- *
- * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-valuecount-aggregation.html
- *
- * @param string $name
- * @param string $field
- *
- * @return ValueCount
- */
- public function value_count($name, $field)
- {
- return new ValueCount($name, $field);
- }
- /**
- * percentiles aggregation.
- *
- * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-percentile-aggregation.html
- *
- * @param string $name the name of this aggregation
- * @param string $field the field on which to perform this aggregation
- *
- * @return Percentiles
- */
- public function percentiles($name, $field = null)
- {
- return new Percentiles($name, $field);
- }
- /**
- * percentile ranks aggregation.
- *
- * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-percentile-rank-aggregation.html
- *
- * @param string $name
- */
- public function percentile_ranks($name)
- {
- throw new NotImplementedException();
- }
- /**
- * cardinality aggregation.
- *
- * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-cardinality-aggregation.html
- *
- * @param string $name
- *
- * @return Cardinality
- */
- public function cardinality($name)
- {
- return new Cardinality($name);
- }
- /**
- * geo bounds aggregation.
- *
- * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-geobounds-aggregation.html
- *
- * @param string $name
- */
- public function geo_bounds($name)
- {
- throw new NotImplementedException();
- }
- /**
- * top hits aggregation.
- *
- * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-top-hits-aggregation.html
- *
- * @param string $name
- *
- * @return TopHits
- */
- public function top_hits($name)
- {
- return new TopHits($name);
- }
- /**
- * scripted metric aggregation.
- *
- * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-scripted-metric-aggregation.html
- *
- * @param string $name
- * @param string|null $initScript
- * @param string|null $mapScript
- * @param string|null $combineScript
- * @param string|null $reduceScript
- *
- * @return ScriptedMetric
- */
- public function scripted_metric($name, $initScript = null, $mapScript = null, $combineScript = null, $reduceScript = null)
- {
- return new ScriptedMetric($name, $initScript, $mapScript, $combineScript, $reduceScript);
- }
- /**
- * global aggregation.
- *
- * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-global-aggregation.html
- *
- * @param string $name
- *
- * @return GlobalAggregation
- */
- public function global_agg($name)
- {
- return new GlobalAggregation($name);
- }
- /**
- * filter aggregation.
- *
- * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-filter-aggregation.html
- *
- * @param string $name
- * @param AbstractQuery $filter
- *
- * @return FilterAggregation
- */
- public function filter($name, AbstractQuery $filter = null)
- {
- return new FilterAggregation($name, $filter);
- }
- /**
- * filters aggregation.
- *
- * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-filters-aggregation.html
- *
- * @param string $name
- *
- * @return Filters
- */
- public function filters($name)
- {
- return new Filters($name);
- }
- /**
- * missing aggregation.
- *
- * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-missing-aggregation.html
- *
- * @param string $name
- * @param string $field
- *
- * @return Missing
- */
- public function missing($name, $field)
- {
- return new Missing($name, $field);
- }
- /**
- * nested aggregation.
- *
- * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-nested-aggregation.html
- *
- * @param string $name
- * @param string $path the nested path for this aggregation
- *
- * @return Nested
- */
- public function nested($name, $path)
- {
- return new Nested($name, $path);
- }
- /**
- * reverse nested aggregation.
- *
- * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-reverse-nested-aggregation.html
- *
- * @param string $name The name of this aggregation
- * @param string $path Optional path to the nested object for this aggregation. Defaults to the root of the main document.
- *
- * @return ReverseNested
- */
- public function reverse_nested($name, $path = null)
- {
- return new ReverseNested($name);
- }
- /**
- * children aggregation.
- *
- * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-children-aggregation.html
- *
- * @param string $name
- */
- public function children($name)
- {
- throw new NotImplementedException();
- }
- /**
- * terms aggregation.
- *
- * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-terms-aggregation.html
- *
- * @param string $name
- *
- * @return Terms
- */
- public function terms($name)
- {
- return new Terms($name);
- }
- /**
- * significant terms aggregation.
- *
- * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-significantterms-aggregation.html
- *
- * @param string $name
- *
- * @return SignificantTerms
- */
- public function significant_terms($name)
- {
- return new SignificantTerms($name);
- }
- /**
- * range aggregation.
- *
- * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-range-aggregation.html
- *
- * @param string $name
- *
- * @return Range
- */
- public function range($name)
- {
- return new Range($name);
- }
- /**
- * date range aggregation.
- *
- * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-daterange-aggregation.html
- *
- * @param string $name
- *
- * @return DateRange
- */
- public function date_range($name)
- {
- return new DateRange($name);
- }
- /**
- * ipv4 range aggregation.
- *
- * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-iprange-aggregation.html
- *
- * @param string $name
- * @param string $field
- *
- * @return IpRange
- */
- public function ipv4_range($name, $field)
- {
- return new IpRange($name, $field);
- }
- /**
- * histogram aggregation.
- *
- * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-histogram-aggregation.html
- *
- * @param string $name the name of this aggregation
- * @param string $field the name of the field on which to perform the aggregation
- * @param int $interval the interval by which documents will be bucketed
- *
- * @return Histogram
- */
- public function histogram($name, $field, $interval)
- {
- return new Histogram($name, $field, $interval);
- }
- /**
- * date histogram aggregation.
- *
- * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-datehistogram-aggregation.html
- *
- * @param string $name the name of this aggregation
- * @param string $field the name of the field on which to perform the aggregation
- * @param int $interval the interval by which documents will be bucketed
- *
- * @return DateHistogram
- */
- public function date_histogram($name, $field, $interval)
- {
- return new DateHistogram($name, $field, $interval);
- }
- /**
- * geo distance aggregation.
- *
- * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-geodistance-aggregation.html
- *
- * @param string $name the name if this aggregation
- * @param string $field the field on which to perform this aggregation
- * @param string|array $origin the point from which distances will be calculated
- *
- * @return GeoDistance
- */
- public function geo_distance($name, $field, $origin)
- {
- return new GeoDistance($name, $field, $origin);
- }
- /**
- * geohash grid aggregation.
- *
- * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-geohashgrid-aggregation.html
- *
- * @param string $name the name of this aggregation
- * @param string $field the field on which to perform this aggregation
- *
- * @return GeohashGrid
- */
- public function geohash_grid($name, $field)
- {
- return new GeohashGrid($name, $field);
- }
- /**
- * bucket script aggregation.
- *
- * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-pipeline-bucket-script-aggregation.html
- *
- * @param string $name
- * @param array|null $bucketsPath
- * @param string|null $script
- *
- * @return BucketScript
- */
- public function bucket_script($name, $bucketsPath = null, $script = null)
- {
- return new BucketScript($name, $bucketsPath, $script);
- }
- /**
- * serial diff aggregation.
- *
- * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-pipeline-serialdiff-aggregation.html
- *
- * @param string $name
- * @param string|null $bucketsPath
- *
- * @return SerialDiff
- */
- public function serial_diff($name, $bucketsPath = null)
- {
- return new SerialDiff($name, $bucketsPath);
- }
- }
|