Elastica\Aggregation\TopHits::setFrom PHP Method

setFrom() public method

The offset from the first result you want to fetch.
public setFrom ( integer $from )
$from integer
    public function setFrom($from)
    {
        return $this->setParam('from', (int) $from);
    }

Usage Example

Example #1
0
 /**
  * @group functional
  */
 public function testAggregateTwoDocumentPerTagWithOffset()
 {
     $aggr = new TopHits('top_tag_hits');
     $aggr->setSize(2);
     $aggr->setFrom(1);
     $aggr->setSort(array('last_activity_date' => array('order' => 'desc')));
     $resultDocs = array();
     $outerAggrResult = $this->getOuterAggregationResult($aggr);
     foreach ($outerAggrResult['buckets'] as $bucket) {
         foreach ($bucket['top_tag_hits']['hits']['hits'] as $doc) {
             $resultDocs[] = $doc['_id'];
         }
     }
     $this->assertEquals(array(2, 4), $resultDocs);
 }