Skip to content

Commit 3a9ded0

Browse files
committed
Add Elastica\Facet\DateHistogram::setFactor()
1 parent 12f7fdd commit 3a9ded0

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

lib/Elastica/Facet/DateHistogram.php

+11
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,17 @@ public function setTimezone($tzOffset)
2424
return $this->setParam('time_zone', $tzOffset);
2525
}
2626

27+
/**
28+
* Set the factor parameter
29+
*
30+
* @param integer $factor
31+
* @return $this
32+
*/
33+
public function setFactor($factor)
34+
{
35+
return $this->setParam('factor', $factor);
36+
}
37+
2738
/**
2839
* Creates the full facet definition, which includes the basic
2940
* facet definition of the parent.

test/lib/Elastica/Test/Facet/DateHistogramTest.php

+6-5
Original file line numberDiff line numberDiff line change
@@ -28,22 +28,23 @@ public function testTest()
2828

2929
$mapping = new Mapping($type, array(
3030
'name' => array('type' => 'string', 'store' => 'no'),
31-
'dtmPosted' => array('type' => 'date', 'store' => 'no', 'format' => 'yyyy-MM-dd HH:mm:ss'),
31+
'dtmPosted' => array('type' => 'long', 'store' => 'no'),
3232
));
3333
$type->setMapping($mapping);
3434

35-
$doc = new Document(1, array('name' => 'nicolas ruflin', 'dtmPosted' => "2011-06-23 21:53:00"));
35+
$doc = new Document(1, array('name' => 'nicolas ruflin', 'dtmPosted' => 1308865980));
3636
$type->addDocument($doc);
37-
$doc = new Document(2, array('name' => 'raul martinez jr', 'dtmPosted' => "2011-06-23 09:53:00"));
37+
$doc = new Document(2, array('name' => 'raul martinez jr', 'dtmPosted' => 1308822780));
3838
$type->addDocument($doc);
39-
$doc = new Document(3, array('name' => 'rachelle clemente', 'dtmPosted' => "2011-07-08 08:53:00"));
39+
$doc = new Document(3, array('name' => 'rachelle clemente', 'dtmPosted' => 1310115180));
4040
$type->addDocument($doc);
41-
$doc = new Document(4, array('name' => 'elastica search', 'dtmPosted' => "2011-07-08 01:53:00"));
41+
$doc = new Document(4, array('name' => 'elastica search', 'dtmPosted' => 1310089980));
4242
$type->addDocument($doc);
4343

4444
$facet = new DateHistogram('dateHist1');
4545
$facet->setInterval("day");
4646
$facet->setField("dtmPosted");
47+
$facet->setFactor(1000);
4748

4849
$query = new Query();
4950
$query->addFacet($facet);

0 commit comments

Comments
 (0)