How can I set searchableAttributes on an instantsearch widget?

I am trying to set searchable attributes so that these can by dynamically controlled by locale. I am attempting to follow this guide from algolia on multi lang support:

The example shows setting this value on index:


but this is not how I am creating my index, maybe I am missing something?

    searchable_terms_array = [

    restricted_terms_array = [
      'title_' + current_locale

    search = instantsearch(
      appId: 'MY-ID'
      apiKey: 'MY_KEY'
      indexName: 'my_index_' + rails_env
      urlSync: {
        threshold: 300
        getHistoryState: ->
          { turbolinks: true }
      searchFunction: (helper) ->
        query = search.helper.state.query
        helper.setQueryParameter('searchableAttributes', searchable_terms_array)  # doesn't seem to work
        helper.setQueryParameter('restrictSearchableAttributes', restricted_terms_array)
        videos.helper.setQuery query

Hello @thomasjosephbush,

searchableAttributes parameter needs to be set via setSettings method in your backend. It’s scope is only settings and therefore it cannot be set as query parameter when you search.

The instantsearch.js code you pasted in you message is intended to only perform search operations and no indexing operations. And you can only restrict searchable attribute there - that one is correct.

So in order to make it work, you need to move the setting of searchableAttributes to your backend where you index your data and create your indices.