Instantsearch.js and getSettings

I can’t find any example how to use getSettings in instantsearch.js


Hi there,

Thank you for your question.

The getSettings method is used more in the backend operation and can’t be used on instantsearch. More information can be found here.

Having said that if you have a specific use case by using the settings in the frontend I may be able to find other alternative solutions.

Please let me know.


Thank you for your reply.
I found the follow usage of getSettings in javascript:

index.getSettings(function (err, content) {
        if (content.attributesForFaceting) {
            content.attributesForFaceting.forEach(function (item, index, arr) {
                var productString;

                if (item.indexOf('searchable(') >= 0) {
                    productString = item.slice(item.indexOf('(') + 1, item.indexOf(')'));
                else {
                    productString = item;

                var newDiv = document.createElement('div');
       = index + "-widgetArea";

This example is absolutely my case.
The amount of filter blocks (category, subcategory, brand, and so on) are depends on certain product.
So, I need somehow to show them up.


What you’re looking for is setting facets to * (using configure({ facets: ['*'] })), then you can loop over the response to display all possible facets using the widgets

Thanks for replying.
Could you please give more details?
Maybe a snapshot of the code or the documentation.

slightly different than what I suggested, now that I realise dynamic widgets is released:

    facets: ['*'],
    container: '#facets',
    transformItems(_, { results }) {
      // use the raw results from *
      return Object.keys(results._rawResults[0].facets);
    // list every possible widget once and map
    // also possible to statically list those without mapping
    widgets: [
    ].map((attribute) => (container) =>
        templates: {
          header({ widgetParams: { attribute } = {} } = {}) {
            return attribute;
      })(instantsearch.widgets.refinementList)({ container, attribute })

doc for dynamic widgets: dynamicWidgets | InstantSearch.js | API parameters | API Reference | Algolia Documentation