如何使用Laravel 5在elasticsearch中分页
我是elasticsearch的新手,我想在其中使用分页 我使用的是from和size。我现在总共有10张唱片,我正在从0到0,从5到大小。我得到了5个结果。但是,如何提供查看页面的链接,以及如何增加第二页的记录 我的查询:如何使用Laravel 5在elasticsearch中分页,laravel,
elasticsearch,laravel-5,pagination,Laravel,
elasticsearch,Laravel 5,Pagination,我是elasticsearch的新手,我想在其中使用分页 我使用的是from和size。我现在总共有10张唱片,我正在从0到0,从5到大小。我得到了5个结果。但是,如何提供查看页面的链接,以及如何增加第二页的记录 我的查询: $params = [ 'index' => 'my_index', 'type' => 'product', 'body' => [
$params = [
'index' => 'my_index',
'type' => 'product',
'body' => [
"sort" =>[
["default_product_low_price.sale_price" => ["order" => $sort]]
],
"from" => 0, "size" =>5,
'query'=> $query,
]
];
$response = \Es::Search($params);
这是我现在的查询,在存储库中哪里提供分页链接?
$params['size'] = $per_page;
$params['from'] = $from;
$params['index'] = config('elastic.Admin_Logs');
$params['type'] = config('elastic.Admin_Type');
$params['body']['sort']['default_product_low_price.sale_price']['order'] = "desc";
$params['body']['query']['filtered']['filter']['bool']['must'][]['match_all'] = [];
$response = \Es::Search($params);
$access = $response['hits'];
return $access;
在控制器中,我设置$per_page和$from
$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());
现在在视图{{!!$admin_exceptions->render()!!}中使用render in,您是否尝试过
{!!$variable->links()!!}
?是的,先生,我尝试过,但它显示了错误,如:“调用数组上的成员函数links()”我将{!!$item hits']->links()}是吗?请看我的回答:谢谢,先生,但如何在查看页面中显示分页链接?