Shopify - Ignore some products from a particular search

Our client is using Algolia in Shopify and would like the ability to exclude certain products from a given search. Is there any straightforward way to do this in Algolia or through customization of the algolia_instant_search.js/templating files?

Any help on this is greatly appreciated!

We do have actually two ways to exclude products from being indexed.
Those are described in this section of the documentation:
https://community.algolia.com/shopify/index-schema.html#ignoring-a-product .

1 Like

Thank you so much for the fast response! We still want the products to be indexed, but we want to exclude them under some search terms where they would otherwise appear. Is there a way to ignore products under a given search?

You could add a specific exclude filter.
For instance, if you were to add a specific tag for the products you don’t want for the search abc, you could then use addExcludeRefinement('tags', 'abc-search-ignore') .

So in the end, you would be looking at a custom widget like this one:

{
  getConfiguration: function () {
    facets: ['tags']
  },
  render: function (opts) {
    var helper = opts.helper;
    var state = opts.state;
    if (state.query !== 'abc' && helper.isExcluded('tags', 'abc-search-ignore') {
      // If query isn't abc, remove the exclusion
      helper.removeExcludeRefinement('tags', 'abc-search-ignore');
      helper.search();
    } else if (state.query === 'abc' && !helper.isExcluded('tags', 'abc-search-ignore') {
      // If query is abc, add the exclusion
      helper.addExcludeRefinement('tags', 'abc-search-ignore');
      helper.search();
    }
  }
}