Search code examples
algoliainstantsearch.jsinstantsearch

Algolia InstantSearch.js' searchFunction parameter not working


Algolia's InstantSearch.js is working really great. However, its searchFunction parameter doesn't seem to be working according to their docs. Here's my search object:

const search = instantsearch({
    indexName: 'decks',
    searchClient,
    routing: true,
    searchParameters: { hitsPerPage: 10 },
    searchFunction(helper) {
        console.log('hi')
    }
})

Nothing ever gets written to the console and search functionality remains the same. So, it seems searchFunction is never called. I'm using InstantSearch.js v3.0.0, has searchFunction maybe been renamed to something else?


Solution

  • searchFunction does in fact work as an argument to instantsearch. Even though I had previously reset my browser to avoid caching issues and did a view source to make sure updated JavaScript code was being loaded, I apparently had an older version of the code running.

    Hopefully this helps someone else. Though I suppose this is now a Chrome caching issue rather than an InstantSearch.js issue.