Algolia Javascript InstantSearch increase the items searchable from algolia


I am indexing Algolia for a search of paintings. I have over 25000 items of data, currently I can show 1000 items on a map. I am using JS on the client-side. What is the best course of action to add all 25000 items onto the map. From using the paginationLimitedTo function or the index.browseAll() functions it seems that I need to use the Algolia admin API key. Currently I am using the search only API key.

Any help would be very much appreciated to add all items to the map using the current implementation of Algolia search that I have


Hi @elena,

Indeed, you are experiencing the 1000 hit limit we set for security purposes. We don’t want malicious users to be able to get all your data through a search with unlimited result!

You correctly noted the browseAll method which we offer to retrieve all your records, but this does require your Admin API Key so should not be exposed through client-side JS.

Taking a step back, Algolia is not a database but instead an index optimized for search. If you would like to load 25,000 points onto a Leaflet map, I would suggest loading that directly from your database. It sounds like this would be your first map render to the user.

The appropriate place for Algolia to come in might be when your users actually initiate a search, at which point you can then clear the map of the 25,000 points and retrieve relevant records from Algolia using the selected Algolia search refinements/params.

Will that work for you?

I thought that would be the case. Thanks @ajay.david

@ajay.david Another query is that I wish to have the results matching the items on the Leaflet map. Currently, I have a map.on('zoomend') function that gets the map’s bounds when the zoom is changed. How can I make a search based on the items showing on the map. The function that I thought would work was search.helper.setQueryParameter('insideBoundingBox', boundingBox).search(); where boundingBox is an array containing the map’s lat/lng coordinates, but I am getting the error - TypeError: is not a function.

I’d really appreciate your advise

Hi elena. We do something similar in our application. I found that using the searchFunction when initializing your search is the way to go. There was a bug with pagination and helper, and I’m not sure it has been resolved yet.

We have a mapBounds function that pulls the current boundaries and use that inside here.

const search = (() =>
      searchClient: algoliaClient,
      // searchFunction apparently breaks pagination
      searchFunction: (helper) => {
        const bbox = mapBounds().join();
        helper.setState(helper.state.setQueryParameter('insideBoundingBox', bbox));;
1 Like