esClient = $esClient; $this->configuration = $configuration; $this->criteriaToEsRequest = new CriteriaToEsRequest(); $this->esResponseToResult = new EsResponseToResult(); } /** * @throws ServerResponseException * @throws ClientResponseException */ public function search(Criteria $criteria): Result { $request = $this->criteriaToEsRequest->fromCriteria($criteria); $response = $this->esClient->search([ 'index' => $this->configuration->getIndexName(), 'body' => $request->es(), ]); return $this->esResponseToResult->fromResponse($response); } }