Instantsearch.js: Ignore facet

Created on 23 Jul 2019  路  2Comments  路  Source: algolia/instantsearch.js

I checked the docs but was not able to find a solution in v3 to exclude a certain facet using searchParameters.

What I'm basically trying to accomplish is that when a user is logged into our system (TYPO3), a special class is added to the body. If this class is set, I want to display every record there is (regular search). But if that class is not set, I need to exclude the facet intern which is set to 1.

Since facetsExcludes has been removed I'd like to know how I can accomplish such behaviour.

Screen Shot 2019-07-23 at 14 07 39

if ( $('body').hasClass('intern') !== true ){
var search = instantsearch({
    indexName: 'indexname',
    searchClient,
    routing: false,
    searchParameters: {
        WHAT-SHOULD-I-PUT-HERE-TO-IGNORE-INTERN-1: {
            "intern": 1
        }
    }
});
}

I don't want to prefilter anything, though.

Most helpful comment

The API parameter filters is what you're looking for.

This should work:

var search = instantsearch({
  indexName: 'indexname',
  searchClient,
  searchParameters: {
    filters: 'NOT intern:1',
  },
});

All 2 comments

The API parameter filters is what you're looking for.

This should work:

var search = instantsearch({
  indexName: 'indexname',
  searchClient,
  searchParameters: {
    filters: 'NOT intern:1',
  },
});

That was too simple. :) Thanks a lot.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

proudlygeek picture proudlygeek  路  4Comments

francoischalifour picture francoischalifour  路  3Comments

ChristopherDosin picture ChristopherDosin  路  4Comments

jvreeken picture jvreeken  路  3Comments

bobylito picture bobylito  路  3Comments