/** * Tests setters & getters. */ public function testSetterGetter() { $this->specify('sorts can be set and get', function () { $this->sort->setSorts([$this->sortBuilder->createFieldSort()->setField('f'), $this->sortBuilder->createScoreSort()]); verify($this->sort->getSorts())->count(2); }); $this->specify('sort can be added and get', function () { $this->sort->addSort($this->sortBuilder->createScoreSort()); verify($this->sort->getSorts())->count(1); }); }
/** * @inheritdoc */ public function _before() { $service = new \Nord\Lumen\Elasticsearch\ElasticsearchService(\Elasticsearch\ClientBuilder::fromConfig([])); $queryBuilder = $service->createQueryBuilder(); $this->search = $service->createSearch(); $this->query = $queryBuilder->createBoolQuery(); $this->query->addMust($queryBuilder->createTermQuery()->setField('field1')->setValue('value1')); $sortBuilder = $service->createSortBuilder(); $this->sort = $service->createSort(); $this->sort->addSort($sortBuilder->createScoreSort()); $aggregationBuilder = $service->createAggregationBuilder(); $this->aggregation = $aggregationBuilder->createGlobalAggregation(); $this->aggregation->setName('global_name'); $this->aggregation->addAggregation($aggregationBuilder->createMinAggregation()->setField('field_name')->setName('min_name')); $this->aggregation->addAggregation($aggregationBuilder->createMaxAggregation()->setField('field_name')->setName('max_name')); }