How can i get the total number of records in an index, with algolia?
I'd like to avoid doign an empty search with a number of items per page set to a million or something.
Every search result from Algolia has an attribute of nbHits. To get the total number of records, do an empty query with no filters and grab that number.
If you care about the size of the results, you can also set the attributesToRetrieve to null which will return only the objectID and make the result a bit snappier.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With