I have a model, let's call it Entry
.
In a view, I have a paginated table (35 per page) with a search bar that lists every entry.
When the view loads, meilisearch
is called to retrieve the first page of results. This is done with a search
query using the search bar's value (it starts out empty). The initial query to the search endpoint is q="", limit=35, offset=0
.
When I click on the pagination buttons, meilisearch
is called again, using the page number for the offset. For example, for page 2 the query should be q="", limit=35, offset=35
.
This works up until page 30. Then no results are shown, even though I have more than 100 pages worth of entries
in my database.
I didn't know why this happened and assumed it was something weird going on with the laravel/scout
or meilisearch/meilisearch-php
. After some debugging, I found nothing and decided to run the query myself using cURL.
curl \
-H "Authorization: Bearer my-meilisearch-key" \
-H "Content-type: application/json" \
http://127.0.0.1:7700/indexes/my-index/search
-d '{"q":"","limit":5,"offset":1000}'
The results are below.
Just to be clear, it I had used offset: 999
, the search would have returned 1 hit. 1000 is a very peculiar number so I'm wondering if there's a configuration value somewhere that I could tweak to get as many results as I possibly can?
CodePudding user response:
After asking around, I got the answer I needed on Discord by the user Rapand.
As I suspected, Meilisearch did have a default 1000 results per search limit. This is configured by the maxTotalHits
pagination option. To quote from their documentation :
maxTotalHits
takes priority over search parameters such aslimit
,offset
,hitsPerPage
, andpage
.For example, if you set
maxTotalHits
to 100, you will not be able to access search results beyond 100 no matter the value configured foroffset
.
To update my pagination's limits, I just ran
curl \
-X PATCH 'http://localhost:7700/indexes/my-index/settings/pagination' \
-H 'Authorization: Bearer my-meilisearch-key' \
-H 'Content-type: application/json' \
-d '{"maxTotalHits": 20000}'