public function search($keyword, array $filters = []) { $query = ['index' => 'eshop', 'type' => 'product', 'body' => ['query' => ['term' => ['title' => $keyword]]]]; // add limit if (isset($filters['limit'])) { $query['size'] = $filters['limit']; if (isset($filters['offset'])) { $query['from'] = $filters['offset']; } } $result = $this->es->search($query); $return = ['total' => $result['hits']['total'], 'products' => []]; foreach ($result['hits']['hits'] as $product) { $return['products'][] = $product['_source']; } return $return; }