1chbinamin's avatar

Pagination with Meilisearch shows more results after clicking on last link.

Meilisearch and the whole webapp itself work. But when I click on a last item number on the pagination element, it shows me more pagination links plus more total results based on the search query than it actually is. For example: I use "qui minima" as query param for Meilisearch to return the results. The page renders 4 pagination links and it also says "Showing 1 to 20 of 74 results" which is correct because on localhost port 7700 (the Meilisearch service itself) would also return 74 results based on that same query. But the moment when I click on the last fourth pagination link, 4 more pagination links are added which makes it in total 8 and it says "Showing 61 to 80 of 146 results". This is wrong because it should always be 74 results in total.

Here is my code: Blade view, pagination links:

<div class="pt-5">{{ $assignments->links() }}</div>

Blade view, form input where you can enter query:

<form action="{{ route('index') }}" method="get"><div class="filters_container"><label for="query" class="w-full"><input type="text" name="query" id="query" class="query"></label></div></form>

A piece from controller method 'Index ' where Meilisearch does its work searching and performing pagination:

$assignments = Assignment::search($request['query'])->paginate(20);

How can I make sure to prevent this weird behaviour. In this case, 74 results should always stay 74 results even after clicking on the last pagination link.

1 like
2 replies
JohnnyBigodes's avatar

Do you have a solution for your problem? I am having the same behaviour.

Thanks

1chbinamin's avatar

@JohnnyBigodes I've somehow solved it. But it was just a hobby project and I've deleted it lol. It's been a long time.

Please or to participate in this conversation.