/**
  * Tests setters & getters.
  */
 public function testSetterGetter()
 {
     $this->specify('index can be set and get', function () {
         $this->search->setIndex('index');
         verify($this->search->getIndex())->equals('index');
     });
     $this->specify('type can be set and get', function () {
         $this->search->setType('doc');
         verify($this->search->getType())->equals('doc');
     });
     $this->specify('query can be set and get', function () {
         $this->search->setQuery($this->query);
         verify($this->search->getQuery())->isInstanceOf('\\Nord\\Lumen\\Elasticsearch\\Search\\Query\\Compound\\BoolQuery');
     });
     $this->specify('page can be set and get', function () {
         $this->search->setPage(1);
         verify($this->search->getPage())->equals(1);
     });
     $this->specify('size can be set and get', function () {
         $this->search->setSize(100);
         verify($this->search->getSize())->equals(100);
     });
     $this->specify('sort can be set and get', function () {
         $this->search->setSort($this->sort);
         verify($this->search->getSort())->isInstanceOf('\\Nord\\Lumen\\Elasticsearch\\Search\\Sort');
     });
     $this->specify('aggregation can be added and collection retrieved', function () {
         $this->search->addAggregation($this->aggregation);
         $collection = $this->search->getAggregations();
         verify($collection)->isInstanceOf('\\Nord\\Lumen\\Elasticsearch\\Search\\Aggregation\\AggregationCollection');
     });
 }
 /**
  * @param int|null $offset
  * @param int|null $length
  * @return array
  */
 public function getResult($offset = null, $length = null)
 {
     if (!is_null($offset) && !is_null($length)) {
         $page = $offset / $length + 1;
         $size = $length;
         if ($page !== $this->search->getPage() || $size !== $this->search->getSize()) {
             $this->result = null;
             $this->search->setPage($page)->setSize($size);
         }
     }
     if (empty($this->result)) {
         $this->result = $this->elasticsearch->execute($this->search);
     }
     return $this->result;
 }