首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >elasticsearch laravel的分页

elasticsearch laravel的分页
EN

Stack Overflow用户
提问于 2016-03-01 09:56:20
回答 1查看 5.4K关注 0票数 3

我正在使用shift31 31/laravel-elasticsearch:~1.0。我想在我的列表页面上实现分页。

搜索代码:

代码语言:javascript
复制
   $params = [
        'index' => 'my_index',
        'type' => 'product',
        'body' =>  [
                       'query'=>[
                                 'match'=>[
                                           'category'=>$category
                                          ]
                                 ]
                   ];
   ];
  $response = \Es::Search($params);

如何在上述查询中使用分页?

更新:

我在查询中使用from和size,但是如何在视图页面中给出分页链接?以及如何通过点击页面进行更新?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-03-01 11:45:32

储存库

代码语言:javascript
复制
 $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;

我在控制器中设置了$per_page和$from

代码语言:javascript
复制
$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。

票数 10
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/35719728

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档