date_histogram() public method

date histogram aggregation.
public date_histogram ( string $name, string $field, integer $interval ) : DateHistogram
$name string the name of this aggregation
$field string the name of the field on which to perform the aggregation
$interval integer the interval by which documents will be bucketed
return Elastica\Aggregation\DateHistogram
Ejemplo n.º 1
0
 /**
  * @param string $term
  * @param string $value
  * @param int    $size
  *
  * @return \Elastica\ResultSet
  */
 public function termQuery($term, $value, $size = 30)
 {
     $_agg = new Aggregation();
     $_facet = $_agg->date_histogram('occurred_on', '@timestamp', ElkIntervals::DAY);
     //        $_facet = new DateHistogram('occurred_on');
     //        $_facet->setField('@timestamp');
     //        $_facet->setInterval('day');
     $_query = new Query();
     $_query->setSize($size);
     $_query->setSort(['@timestamp']);
     //	Filter for term
     $_filter = new Prefix($term, $value);
     $_and = new Bool();
     $_and->addMust($_filter);
     $_query->setPostFilter($_and);
     $_query->addAggregation($_facet);
     $_results = $this->_doSearch($_query);
     return $_results;
 }