How to request a filtered version of an index in instantsearch?

Hey everyone,

I’d need some advices to build a search, I’m using instantsearch 1.11 for that.
The indice is used in two different search boxes. The indice has a facet based on a boolean flag.

How can I configure instantsearch to directly display the results for flag == false ?
Is it in searchParameters ?

Cheers.


I replied to myself this morning, but it seems I can’t reply.
@marielaure.thuret what’s the difference with
searchParameters: {
facetFilters: [‘flag:true’]
}
which seems to work, as well.
@Bobylito yep it was quick to set up \o/

Hi Bruno,

You’re right it’s by using searchParameters. See https://community.algolia.com/instantsearch.js/documentation/#default-filters

I wrote a little jsfiddle: https://jsfiddle.net/8qj1p93z/1/

It show records that have free_shipping to true.

Is what you’re expecting?

Hi Bruno :wave: happy to see that you’re using InstantSearch.js \o/.

Found the answer here https://www.algolia.com/doc/api-reference/api-parameters/facetFilters/

Sorry for the late answer @bruno

Well the difference is that facetFilters is a parameter of the API, whereas the facetRefinements is a parameter of the helper (the state manager of InstantSearch) which will be translated into facetFilters when the query is done.

As for “which one should I use?”, you should probably go for facetRefinements if you’re in the context of instantsearch.js.

More infos on the subject of the managed parameters in the concepts guide of the helper.