How to get all hits using instantsearch.js

In the app I am building, users can opt to select and download all documents associated with the current search. When the search returns only a 10 or less results, this is easy because all the info I need is available in this hits. However, when the results span multiple pages, I don’t have access to the data I need to facilitate a “Download All.”

Was wondering then, can I programmatically get all hits so that I can get the information I need to implement this? That is, I need the get an array of Obj.file_name for each object in the search’s complete result set.

Thanks
Eric

Hi @ecoffman, to do this you can create an API route on your own server and then use an API client to use the browse method to get the full content of your index.

If you are using InstantSearch.js, you could do something like this: https://jsfiddle.net/s3ap8pew/1/

This is a complete example showing you how to get the underlying query of InstantSearch.js and reuse it on your end to get all the results.

Let us know how it goes.

1 Like

Thank you vvo, That is, in fact, what I did. I am using the API search to implement this functionality.

Thank you!