Pagination in elasticsearch laravel

I am using shift31 / laravel-elasticsearch: ~ 1.0. I want to implement pagination on a list page.

Search Code:

$params = [ 'index' => 'my_index', 'type' => 'product', 'body' => [ 'query'=>[ 'match'=>[ 'category'=>$category ] ] ]; ]; $response = \Es::Search($params); 

How to use pagination in the request above?

Update:

I used and set the size in the request, but how to specify a link to a page paginated? and how to update by clicking on the page?

+2
source share
1 answer

in the repository

  $params = [ 'index' => 'my_index', 'type' => 'product', 'size' = $per_page; 'from' = $from; 'body' => [ 'query'=>[ 'match'=>[ 'category'=>$category ] ] ]; ]; $response = \Es::Search($params); $access = $response['hits']; return $access; 

i sets $ per_page and $ from the controller

 $per_page = $request->get('limit', 10); $from = ($request->get('page', 1) - 1) * $per_page; $access = $this->repository->Index($per_page, $from); $admin_exceptions = new LengthAwarePaginator( $access['hits'], $access['total'], $per_page, Paginator::resolveCurrentPage(), ['path' => Paginator::resolveCurrentPath()]); return view('adminexception.index', compact('admin_exceptions'))->withInput($request->all()); 

and now use render in in the {{!! $ admin_exceptions-> render () !!}}

+2
source

All Articles