\Elastica\AggregationScriptedMetric

Class ScriptedMetric.

Summary

Methods
Properties
Constants
__construct()
setCombineScript()
setInitScript()
setMapScript()
setReduceScript()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
No private properties found
N/A

Methods

__construct()

__construct(string  $name, string|null  $initScript = null, string|null  $mapScript = null, string|null  $combineScript = null, string|null  $reduceScript = null) 

Parameters

string $name

the name if this aggregation

string|null $initScript

Executed prior to any collection of documents

string|null $mapScript

Executed once per document collected

string|null $combineScript

Executed once on each shard after document collection is complete

string|null $reduceScript

Executed once on the coordinating node after all shards have returned their results

setCombineScript()

setCombineScript(string  $script) : $this

Executed once on each shard after document collection is complete.

Allows the aggregation to consolidate the state returned from each shard. If a combine_script is not provided the combine phase will return the aggregation variable.

Parameters

string $script

Returns

$this

setInitScript()

setInitScript(string  $script) : $this

Executed prior to any collection of documents.

Allows the aggregation to set up any initial state.

Parameters

string $script

Returns

$this

setMapScript()

setMapScript(string  $script) : $this

Executed once per document collected.

This is the only required script. If no combine_script is specified, the resulting state needs to be stored in an object named _agg.

Parameters

string $script

Returns

$this

setReduceScript()

setReduceScript(string  $script) : $this

Executed once on the coordinating node after all shards have returned their results.

The script is provided with access to a variable _aggs which is an array of the result of the combine_script on each shard. If a reduce_script is not provided the reduce phase will return the _aggs variable.

Parameters

string $script

Returns

$this