Query about Search API's Result Details
TLDR Shawn asked if the search API returns total pages. Jason clarified that it does not, yet it provides data necessary for the calculation.
Powered by Struct AI
2
4
9mo
Solved
Jan 19, 2023 (9 months ago)
Shawn
Shawn
04:00 PMWhen doing a search on a collection does it return the total pages. For example if I have 42 documents found and I have 20 per page it would be 3 pages in total. Does the api return this value? or do you have to calculate this youself? LMK thanks
Jason
Jason
04:02 PMThe search API returns a
found
parameter which is the total number of results founds. Using that, and the per_page
parameter (which defaults to 10) you should be able to calculate the total number of pagesShawn
Shawn
04:03 PMYeah that's what I am doing now. It would be nice if the api just provide that value.
1
04:03
Shawn
04:03 PMThanks Jason.
1
Typesense
Lightning-fast, open source search engine for everyone | Knowledge Base powered by Struct.AI
Indexed 2779 threads (79% resolved)
Similar Threads
Identifying Last Page of Search Results via API
TJ asked if there was a way to know when he's reached the last page of a search result. Jason suggested using the 'found' and 'page' parameters in the API response.
4
2mo
Solved
Calculating Total Pages in Search Request Results
Laura asked how to calculate total pages of search results. Jason suggested using `found / per_page`.
4
4mo
Solved
Retrieving Number of Pages and Total Hits from API Documentation
AK asked about retrieving page count and total hits from API documentation. Kishore Nallan guided them to the "found" field in the response.
4
13mo
Solved