Facet/Filter negative (AND NOT) in React Instant Search

I’ve seen when looking at the algolia docs that for facets it’s possible to say, for e.g.

index.search({
filters: 'category:Book AND NOT category:Ebook'
});

But I can’t figure out how I would apply this behaviour through React Instant Search?
Are there any demo’s or documentation around it? Would I have to apply everything to configure?

Thanks

Hi,

It is actually possible to negate filters by using the Algolia API like you found out.
We also have syntactic sugar in react-instantsearch where you can add a - (minus sign) before a facet to negate it.

Unfortunately, we do not have a UI widget that embeds a negative and a normal filter.

Can you explain me what type of UI would you like to achieve?

Cheers, Maxime.

Thanks for the response @iam4x.

I presume it’s not recommended to mix both the API and React InstantSearch version?

I am using the custom connectors to connect to the refinementList, and so when i refine the props, is that where i can add a - sign?

As a crude example, if we imagined we categorised countries flags by the colors they contain, then the very basic UI i’d be looking for something like this:

[ + ] [ - ] Red
[ + ] [ - ] Blue

Whereby a user can select they want to see items that are attached to the red category, but are not attached to the blue category. (So they wouldn’t see the french or american flag, but they would see the Italian flag for e.g.)

Does that make sense?

Thanks