class BucketAutoOutput extends AbstractOutput (View source)

Fluent interface for adding an output specification to a bucket stage.

Properties

protected Builder $builder from Stage
protected AbstractBucket $bucket from AbstractOutput

Methods

__construct(Builder $builder, AbstractBucket $bucket)

No description

array
getExpression()

Assembles the aggregation stage

execute(array $options = [])

Executes the aggregation pipeline

from Stage
bucket()

Categorizes incoming documents into groups, called buckets, based on a specified expression and bucket boundaries.

from Stage
bucketAuto()

Categorizes incoming documents into a specific number of groups, called buckets, based on a specified expression.

from Stage
collStats()

Returns statistics regarding a collection or view.

from Stage
count($fieldName)

Returns a document that contains a count of the number of documents input to the stage.

from Stage
facet()

Processes multiple aggregation pipelines within a single stage on the same set of input documents.

from Stage
geoNear(float|array|Point $x, float $y = null)

Outputs documents in order of nearest to farthest from a specified point.

from Stage
array
getPipeline()

Returns the assembled aggregation pipeline

from Stage
graphLookup(string $from)

Performs a recursive search on a collection, with options for restricting the search by recursion depth and query filter.

from Stage
group()

Groups documents by some specified expression and outputs to the next stage a document for each distinct grouping.

from Stage
indexStats()

Returns statistics regarding the use of each index for the collection.

from Stage
limit(int $limit)

Limits the number of documents passed to the next stage in the pipeline.

from Stage
lookup(string $from)

Performs a left outer join to an unsharded collection in the same database to filter in documents from the “joined” collection for processing.

from Stage
match()

Filters the documents to pass only the documents that match the specified condition(s) to the next pipeline stage.

from Stage
Out
out(string $collection)

Takes the documents returned by the aggregation pipeline and writes them to a specified collection. This must be the last stage in the pipeline.

from Stage
project()

Passes along the documents with only the specified fields to the next stage in the pipeline. The specified fields can be existing fields from the input documents or newly computed fields.

from Stage
redact()

Restricts the contents of the documents based on information stored in the documents themselves.

from Stage
replaceRoot(string|null $expression = null)

Promotes a specified document to the top level and replaces all other fields.

from Stage
sample(int $size)

Randomly selects the specified number of documents from its input.

from Stage
skip(int $skip)

Skips over the specified number of documents that pass into the stage and passes the remaining documents to the next stage in the pipeline.

from Stage
sortByCount(string $expression)

Groups incoming documents based on the value of a specified expression, then computes the count of documents in each distinct group.

from Stage
sort(array|string $fieldName, int|string $order = null)

Sorts all input documents and returns them to the pipeline in sorted order.

from Stage
unwind(string $fieldName)

Deconstructs an array field from the input documents to output a document for each element. Each output document is the input document with the value of the array field replaced by the element.

from Stage
$this
addToSet(mixed|Expr $expression)

Returns an array of all unique values that results from applying an expression to each document in a group of documents that share the same group by key. Order of the elements in the output array is unspecified.

$this
avg(mixed|Expr $expression)

Returns the average value of the numeric values that result from applying a specified expression to each document in a group of documents that share the same group by key. Ignores nun-numeric values.

$this
expression(mixed|Expr $value)

Used to use an expression as field value. Can be any expression.

$this
field(string $fieldName)

Set the current field for building the expression.

$this
first(mixed|Expr $expression)

Returns the value that results from applying an expression to the first document in a group of documents that share the same group by key. Only meaningful when documents are in a defined order.

$this
last(mixed|Expr $expression)

Returns the value that results from applying an expression to the last document in a group of documents that share the same group by a field.

$this
max(mixed|Expr $expression)

Returns the highest value that results from applying an expression to each document in a group of documents that share the same group by key.

$this
min(mixed|Expr $expression)

Returns the lowest value that results from applying an expression to each document in a group of documents that share the same group by key.

$this
push(mixed|Expr $expression)

Returns an array of all values that result from applying an expression to each document in a group of documents that share the same group by key.

$this
stdDevPop(mixed|Expr $expression)

Calculates the population standard deviation of the input values.

$this
stdDevSamp(mixed|Expr $expression)

Calculates the sample standard deviation of the input values.

$this
sum(mixed|Expr $expression)

Calculates and returns the sum of all the numeric values that result from applying a specified expression to each document in a group of documents that share the same group by key. Ignores nun-numeric values.

groupBy($expression)

An expression to group documents by. To specify a field path, prefix the field name with a dollar sign $ and enclose it in quotes.

buckets(int $buckets)

A positive 32-bit integer that specifies the number of buckets into which input documents are grouped.

granularity(string $granularity)

A string that specifies the preferred number series to use to ensure that the calculated boundary edges end on preferred round numbers or their powers of 10.

Details

__construct(Builder $builder, AbstractBucket $bucket)

Parameters

Builder $builder
AbstractBucket $bucket

array getExpression()

Assembles the aggregation stage

Return Value

array

Iterator execute(array $options = [])

Executes the aggregation pipeline

Parameters

array $options

Return Value

Iterator

Bucket bucket()

Categorizes incoming documents into groups, called buckets, based on a specified expression and bucket boundaries.

Each bucket is represented as a document in the output. The document for each bucket contains an _id field, whose value specifies the inclusive lower bound of the bucket and a count field that contains the number of documents in the bucket. The count field is included by default when the output is not specified.

BucketAuto bucketAuto()

Categorizes incoming documents into a specific number of groups, called buckets, based on a specified expression.

Bucket boundaries are automatically determined in an attempt to evenly distribute the documents into the specified number of buckets. Each bucket is represented as a document in the output. The document for each bucket contains an _id field, whose value specifies the inclusive lower bound and the exclusive upper bound for the bucket, and a count field that contains the number of documents in the bucket. The count field is included by default when the output is not specified.

CollStats collStats()

Returns statistics regarding a collection or view.

$collStats must be the first stage in an aggregation pipeline, or else the pipeline returns an error.

Count count($fieldName)

Returns a document that contains a count of the number of documents input to the stage.

Facet facet()

Processes multiple aggregation pipelines within a single stage on the same set of input documents.

Each sub-pipeline has its own field in the output document where its results are stored as an array of documents.

Return Value

Facet

GeoNear geoNear(float|array|Point $x, float $y = null)

Outputs documents in order of nearest to farthest from a specified point.

You can only use this as the first stage of a pipeline.

Parameters

float|array|Point $x
float $y

Return Value

GeoNear

See also

http://docs.mongodb.org/manual/reference/operator/aggregation/geoNear/

array getPipeline()

Returns the assembled aggregation pipeline

Return Value

array

GraphLookup graphLookup(string $from)

Performs a recursive search on a collection, with options for restricting the search by recursion depth and query filter.

Parameters

string $from Target collection for the $graphLookup operation to search, recursively matching the connectFromField to the connectToField.

Return Value

GraphLookup

See also

https://docs.mongodb.org/manual/reference/operator/aggregation/graphLookup/

Group group()

Groups documents by some specified expression and outputs to the next stage a document for each distinct grouping.

IndexStats indexStats()

Returns statistics regarding the use of each index for the collection.

Limit limit(int $limit)

Limits the number of documents passed to the next stage in the pipeline.

Lookup lookup(string $from)

Performs a left outer join to an unsharded collection in the same database to filter in documents from the “joined” collection for processing.

Match match()

Filters the documents to pass only the documents that match the specified condition(s) to the next pipeline stage.

Out out(string $collection)

Takes the documents returned by the aggregation pipeline and writes them to a specified collection. This must be the last stage in the pipeline.

Parameters

string $collection

Return Value

Out

See also

http://docs.mongodb.org/manual/reference/operator/aggregation/out/

Project project()

Passes along the documents with only the specified fields to the next stage in the pipeline. The specified fields can be existing fields from the input documents or newly computed fields.

Redact redact()

Restricts the contents of the documents based on information stored in the documents themselves.

ReplaceRoot replaceRoot(string|null $expression = null)

Promotes a specified document to the top level and replaces all other fields.

The operation replaces all existing fields in the input document, including the _id field. You can promote an existing embedded document to the top level, or create a new document for promotion.

Parameters

string|null $expression Optional. A replacement expression that resolves to a document.

Return Value

ReplaceRoot

Sample sample(int $size)

Randomly selects the specified number of documents from its input.

Skip skip(int $skip)

Skips over the specified number of documents that pass into the stage and passes the remaining documents to the next stage in the pipeline.

SortByCount sortByCount(string $expression)

Groups incoming documents based on the value of a specified expression, then computes the count of documents in each distinct group.

Parameters

string $expression The expression to group by

Return Value

SortByCount

See also

http://docs.mongodb.org/manual/reference/operator/aggregation/sortByCount/

Sort sort(array|string $fieldName, int|string $order = null)

Sorts all input documents and returns them to the pipeline in sorted order.

If sorting by multiple fields, the first argument should be an array of field name (key) and order (value) pairs.

Parameters

array|string $fieldName Field name or array of field/order pairs
int|string $order Field order (if one field is specified)

Return Value

Sort

See also

http://docs.mongodb.org/manual/reference/operator/aggregation/sort/

Unwind unwind(string $fieldName)

Deconstructs an array field from the input documents to output a document for each element. Each output document is the input document with the value of the array field replaced by the element.

Parameters

string $fieldName The field to unwind. It is automatically prefixed with the $ sign

Return Value

Unwind

See also

http://docs.mongodb.org/manual/reference/operator/aggregation/unwind/

$this addToSet(mixed|Expr $expression)

Returns an array of all unique values that results from applying an expression to each document in a group of documents that share the same group by key. Order of the elements in the output array is unspecified.

AddToSet is an accumulator operation only available in the group stage.

Parameters

mixed|Expr $expression

Return Value

$this

See also

http://docs.mongodb.org/manual/reference/operator/aggregation/addToSet/
Expr::addToSet

$this avg(mixed|Expr $expression)

Returns the average value of the numeric values that result from applying a specified expression to each document in a group of documents that share the same group by key. Ignores nun-numeric values.

Parameters

mixed|Expr $expression

Return Value

$this

See also

http://docs.mongodb.org/manual/reference/operator/aggregation/avg/
Expr::avg

$this expression(mixed|Expr $value)

Used to use an expression as field value. Can be any expression.

Parameters

mixed|Expr $value

Return Value

$this

See also

http://docs.mongodb.org/manual/meta/aggregation-quick-reference/#aggregation-expressions
Expr::expression

$this field(string $fieldName)

Set the current field for building the expression.

Parameters

string $fieldName

Return Value

$this

See also

Expr::field

$this first(mixed|Expr $expression)

Returns the value that results from applying an expression to the first document in a group of documents that share the same group by key. Only meaningful when documents are in a defined order.

Parameters

mixed|Expr $expression

Return Value

$this

See also

http://docs.mongodb.org/manual/reference/operator/aggregation/first/
Expr::first

$this last(mixed|Expr $expression)

Returns the value that results from applying an expression to the last document in a group of documents that share the same group by a field.

Only meaningful when documents are in a defined order.

Parameters

mixed|Expr $expression

Return Value

$this

See also

http://docs.mongodb.org/manual/reference/operator/aggregation/last/
Expr::last

$this max(mixed|Expr $expression)

Returns the highest value that results from applying an expression to each document in a group of documents that share the same group by key.

Parameters

mixed|Expr $expression

Return Value

$this

See also

http://docs.mongodb.org/manual/reference/operator/aggregation/max/
Expr::max

$this min(mixed|Expr $expression)

Returns the lowest value that results from applying an expression to each document in a group of documents that share the same group by key.

Parameters

mixed|Expr $expression

Return Value

$this

See also

http://docs.mongodb.org/manual/reference/operator/aggregation/min/
Expr::min

$this push(mixed|Expr $expression)

Returns an array of all values that result from applying an expression to each document in a group of documents that share the same group by key.

Parameters

mixed|Expr $expression

Return Value

$this

See also

http://docs.mongodb.org/manual/reference/operator/aggregation/push/
Expr::push

$this stdDevPop(mixed|Expr $expression)

Calculates the population standard deviation of the input values.

The argument can be any expression as long as it resolves to an array.

Parameters

mixed|Expr $expression

Return Value

$this

See also

https://docs.mongodb.org/manual/reference/operator/aggregation/stdDevPop/
Expr::stdDevPop

$this stdDevSamp(mixed|Expr $expression)

Calculates the sample standard deviation of the input values.

The argument can be any expression as long as it resolves to an array.

Parameters

mixed|Expr $expression

Return Value

$this

See also

https://docs.mongodb.org/manual/reference/operator/aggregation/stdDevSamp/
Expr::stdDevSamp

$this sum(mixed|Expr $expression)

Calculates and returns the sum of all the numeric values that result from applying a specified expression to each document in a group of documents that share the same group by key. Ignores nun-numeric values.

Parameters

mixed|Expr $expression

Return Value

$this

See also

http://docs.mongodb.org/manual/reference/operator/aggregation/sum/
Expr::sum

BucketAuto groupBy($expression)

An expression to group documents by. To specify a field path, prefix the field name with a dollar sign $ and enclose it in quotes.

Parameters

$expression

Return Value

BucketAuto

BucketAuto buckets(int $buckets)

A positive 32-bit integer that specifies the number of buckets into which input documents are grouped.

Parameters

int $buckets

Return Value

BucketAuto

BucketAuto granularity(string $granularity)

A string that specifies the preferred number series to use to ensure that the calculated boundary edges end on preferred round numbers or their powers of 10.

Parameters

string $granularity

Return Value

BucketAuto