andreladocruz's avatar

Scout Pagination acting a little bit strange :)

Hi guys (and girls),

I'm using Algolia as my scout engine.

I'm calling the search method with this code:

$products = Product::search(auth()->user()->client_id .' '. $search)->paginate(\App\DMG\Configuration::getPaginationQty());

\App\DMG\Configuration::getPaginationQty() returns 15.

the returning object is this:

LengthAwarePaginator {#376 ▼
  #total: 16
  #lastPage: 2
  #items: Collection {#361 ▼
    #items: array:11 [▼
      0 => Product {#378 ▶}
      1 => Product {#381 ▶}
      2 => Product {#386 ▶}
      3 => Product {#377 ▶}
      4 => Product {#380 ▶}
      5 => Product {#387 ▶}
      6 => Product {#385 ▶}
      7 => Product {#383 ▶}
      8 => Product {#379 ▶}
      9 => Product {#382 ▶}
      14 => Product {#384 ▶}
    ]
  }
  #perPage: 15
  #currentPage: 1
  #path: "http://localhost/digitalmanager.dev/public/admin/product/list"
  #query: array:1 [▼
    "query" => "4c5dcb60-44a5-11e7-9ab9-837df3983102 "
  ]
  #fragment: null
  #pageName: "page"
}

Can any one figure out why it's jumping from item 9 to 14? if I reduce the pagination quantity to 5, the 14h item gets alone in one page. :) Isn't it kind of wired?

0 likes
1 reply
andreladocruz's avatar
andreladocruz
OP
Best Answer
Level 5

Just got the problem... :)

As it's a development index, it were a little bit messy.

After cleaning and run the

php artisan scout:import

Everything is working fine again. :)

Please or to participate in this conversation.