Skip to content

Commit

Permalink
average aggregation functionality added
Browse files Browse the repository at this point in the history
  • Loading branch information
Tamizh committed Mar 21, 2018
1 parent 6f804fc commit 581bc02
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ Instead of extends the Model class in your models extend the Elasticsearch to us
e) sum_bucket
f) sum
d) date_histogram (with interval option [default - month])
e) avg
5. sort - Sort the query result
Expand Down
13 changes: 13 additions & 0 deletions src/AggregationClause.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,19 @@ public function sum($field)
return $this;
}

/**
* Gives the avg value of a field
* @param string $field Field Name
* @return Tamizh\LaravelEs\AggregationClause
*/
public function avg($field)
{
$this->field = $field;
$this->type = "avg";
$this->aggs_array[$this->type]['field'] = $this->field;
return $this;
}

/**
* Size of the aggregation
* @param integer $size Size of the aggregation result
Expand Down

0 comments on commit 581bc02

Please sign in to comment.