2

I've been trying to filter the initial search with this query parameter from Algolia with no success. What I've read in the docs is you have to add the query parameter and a query string but so far it do the job.

This is the code I've been working with

var search = instantsearch({
  appId: 'API ID',
  apiKey: 'APY KEY SEARCH',
  indexName: 'per_posts_product',
   searchParameters: {
        facets: ['taxonomies.product_cat'],
        facetsRefinements: {'taxonomies.product_cat': 'Dual Daggers'}
    },
  routing: true
});
Volt
  • 71
  • 1
  • 8

1 Answers1

2

The values provided to the facetsRefinements should be an array not a string. Here is an example that shows how to use it:

const search = instantsearch({
  appId: 'APP_ID',
  apiKey: 'API_KEY',
  indexName: 'INDEX_NAME',
  searchParameters: {
    facets: ['taxonomies.product_cat'],
    facetsRefinements: {
      'taxonomies.product_cat': ['Dual Daggers'],
    },
  },
});

Don't forget to declare your attribute as attributesForFaceting inside your index.

Samuel Vaillant
  • 3,667
  • 1
  • 14
  • 21
  • help me please with https://stackoverflow.com/questions/66146951/how-can-i-filter-my-search-by-an-boolean-atrribute –  Feb 11 '21 at 02:34