Skip to content

Commit

Permalink
Merge pull request #947 from markeilander/patch-2
Browse files Browse the repository at this point in the history
Added setMinDocCount and setExtendedBounds options
  • Loading branch information
ruflin committed Oct 7, 2015
2 parents c6ddf4d + d24ae02 commit cb1cafe
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions lib/Elastica/Aggregation/DateHistogram.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,4 +127,39 @@ public function setFormat($format)
{
return $this->setParam('format', $format);
}

/**
* Set extended bounds option.
*
* @param string
*
* @return $this
*/
public function setExtendedBounds($min = '', $max = '')
{
$bounds = array();
$bounds['min'] = $min;
$bounds['max'] = $max;
// switch if min is higher then max
if (strtotime($min) > strtotime($max)) {
$bounds['min'] = $max;
$bounds['max'] = $min;
}
return $this->setParam('extended_bounds', $bounds);
}
/**
* Set minimal document count option.
*
* @param string
*
* @return $this
*/
public function setMinDocCount($count = 0)
{
// switch if min is higher then max
if (is_numeric($count)) {
return $this->setParam('min_doc_count', $count);
}
return $this;
}
}

0 comments on commit cb1cafe

Please sign in to comment.