Skip to content

Commit cb1cafe

Browse files
committed
Merge pull request #947 from markeilander/patch-2
Added setMinDocCount and setExtendedBounds options
2 parents c6ddf4d + d24ae02 commit cb1cafe

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

lib/Elastica/Aggregation/DateHistogram.php

+35
Original file line numberDiff line numberDiff line change
@@ -127,4 +127,39 @@ public function setFormat($format)
127127
{
128128
return $this->setParam('format', $format);
129129
}
130+
131+
/**
132+
* Set extended bounds option.
133+
*
134+
* @param string
135+
*
136+
* @return $this
137+
*/
138+
public function setExtendedBounds($min = '', $max = '')
139+
{
140+
$bounds = array();
141+
$bounds['min'] = $min;
142+
$bounds['max'] = $max;
143+
// switch if min is higher then max
144+
if (strtotime($min) > strtotime($max)) {
145+
$bounds['min'] = $max;
146+
$bounds['max'] = $min;
147+
}
148+
return $this->setParam('extended_bounds', $bounds);
149+
}
150+
/**
151+
* Set minimal document count option.
152+
*
153+
* @param string
154+
*
155+
* @return $this
156+
*/
157+
public function setMinDocCount($count = 0)
158+
{
159+
// switch if min is higher then max
160+
if (is_numeric($count)) {
161+
return $this->setParam('min_doc_count', $count);
162+
}
163+
return $this;
164+
}
130165
}

0 commit comments

Comments
 (0)