Laravel and Automated Facent?

This is a very simple issue that seem to take a lot of my time. So naturally I will ask for some help.

I have some facent filters generated from an array. So in my facent i have filters.color filters.material filters.model … and so many others.

In my JS i have this

    container: '#filters',
    attribute: 'fliters.Color',

Is there a way to have attribute: ‘fliters.Color’, a wildcard like filters.*

This is because I have a lot of filters and no all apply so I do not want to create one div for each filter. plus this is for a customer so I do not want to do that manually every time they add a new filter.
Thank you

Hi there,

If I understand your request correctly, you would like to generate a refinementList for all the nested attributes, in your example in your filter attribute.

Unfortunately, this is not something you can achieve with a wildcard filter like filters.*, because a refinementList only works for a single attribute.

Would it be possible for you to dynamically generate the widgets on the frontend? For example, if you have all the nested attribute names in an array, you could do something like this:

const attributes = ['color', 'material', 'model', /* etc... */];

attributes.foreach((attribute) => {
    container: `#filters-${attribute}`,
    attribute: `fliters.${attribute}`,

Please not that you would also have to create the right containers with the correct names. So for the color attribute, you would need to create the #filters-color container, and so on.

I hope this helps! :smile:

Thank you for the help. That is mostly what I was looking for, I will also have to create a div for the attributes.

However there is no way to know what attribute apply for specific categories. Some will have color some will not. Also not this will still require code change when adding a new filter. Is there any way to get the list of filters from algolia as an array?

You can do this with an extra query which happens before you start InstantSearch like this:[
    indexName: 'myIndex',
    params: {
      facets: "*",
      hitsPerPage: 1,
      page: 0,
      attributesToRetrieve: [],
      attributesToHighlight: [],
      attributesToSnippet: [],
      tagFilters: tagFilters,
      analytics: false,
      clickAnalytics: false,