Пример #1
0
 /**
  * @group functional
  */
 public function testDateRangeSetFormat()
 {
     $agg = new DateRange('date');
     $agg->setField('created');
     $agg->addRange(1390958535000)->addRange(null, 1390958535000);
     $agg->setFormat('m-y-d');
     $query = new Query();
     $query->addAggregation($agg);
     $results = $this->_getIndexForTest()->search($query)->getAggregation('date');
     $this->assertEquals('22-2014-29', $results['buckets'][0]['to_as_string']);
 }
Пример #2
0
 /**
  * @group functional
  */
 public function testDateRangeAggregation()
 {
     $agg = new DateRange('date');
     $agg->setField('created');
     $agg->addRange(1390958535000)->addRange(null, 1390958535000);
     $query = new Query();
     $query->addAggregation($agg);
     $results = $this->_getIndexForTest()->search($query)->getAggregation('date');
     foreach ($results['buckets'] as $bucket) {
         if (array_key_exists('to', $bucket)) {
             $this->assertEquals(1, $bucket['doc_count']);
         } elseif (array_key_exists('from', $bucket)) {
             $this->assertEquals(2, $bucket['doc_count']);
         }
     }
 }