client = $clientBuilderFactory->create(); } public function searchArticles($query, $page = 1, $pageSize = 10) { $from = ($page - 1) * $pageSize; $params = [ 'index' => 'articles', 'body' => [ 'from' => $from, 'size' => $pageSize, 'query' => [ 'match' => [ 'title' => $query, ], ], ], ]; $response = $this->client->search($params); return $response['hits']['hits']; } }