Autocomplete facet filter not working

Hello, I have a custom autocomplete attached to a product field. Works fine, but I am trying to filter by a specific product type (simple) which is help in attribute ‘type_id’

I followed he guide and placed the attribute as a facet in admin: (100% sure is correct index, as I confirmed name)

then placed in the options:

var source = {
                            source: $.fn.autocomplete.sources.hits(algolia_client.initIndex(self.algoliaConfig.indexName + "_products"), sourceOptions),
                            name: 'products',
                            filters: 'type_id:simple',
                            templates: {
                                empty: function (query) {
                                    var template = '<div class="aa-no-results-products">' +
                                        '<div class="title">No products found!</div>';
                                    return template;
                                },
                                suggestion: function (hit, algoliaResponse) {
                                    hit = transformHit(hit, self.algoliaConfig.priceKey);
                                    hit.displayKey = hit.displayKey || hit.name;
                                    return algoliaBundle.Hogan.compile($('#quickorders-autocomplete_products_template_' + self.uniqueid).html()).render(hit);
                                }
                            }
                        };

however, the results is not filtering, and producing other values for type_id

Any help in where I went wrong/what I am missing.

TIA

Hi @AlgoliaforMagento,

Magento uses our instantsearch behind the scenes. You will need to use the ’ `beforeWidgetInitialization’ to set the filters in the configure widget. Filters are a search parameter, so they need to be set in the configure widget instead of the hits widget.

Hi, appreciate the response.
I am not using the widget, via the magento module, site search, but a custom instance attached to custom form fields

I did, just now, having glanced at the code, realise my mistake.
I was placing the filter in the SOURCE config, not as an OPTION to that source.

var sourceOptions = {
                            hitsPerPage: 5,
                            analyticsTags: 'autocomplete_quickorders',
                            filters: 'type_id:simple',
                        };

                        var source = {
                            source: $.fn.autocomplete.sources.hits(algolia_client.initIndex(self.algoliaConfig.indexName + "_products"), sourceOptions),
                            name: 'products',
                            templates: {
                                empty: function (query) {
                                    var template = '<div class="aa-no-results-products">' +
                                        '<div class="title">No products found!</div>';
                                    return template;
                                },
                                suggestion: function (hit, algoliaResponse) {
                                    hit = transformHit(hit, self.algoliaConfig.priceKey);
                                    hit.displayKey = hit.displayKey || hit.name;
                                    return algoliaBundle.Hogan.compile($('#quickorders-autocomplete_products_template_' + self.uniqueid).html()).render(hit);
                                }
                            }
                        };