reactjsalgoliareact-instantsearch

Algolia React InstantSearch filter false and undefined results


I am using React and NextJS and Algolia's React InstantSearch, I am having an issue trying to filter results that do not equal an attribute I currently have. I have buttons where I want to display hits where isNew:true and and another button to show results that are isNew:false as well as hits that do not have this attribute as well, so something like isNew:undefined.

I have tried the Configure connector with <Configure filters="type:Posts AND (NOT isNew:True)" /> but it does not seem to work as it will only always show hits where isNew:false.

Is there a way to have isNew:false always include the undefined hits as well? I want it to show both types of hits when the button is clicked and if a user visits the route with isNew=false declared.


Solution

  • No, you can't. The Algolia engine doesn’t support filtering on null value or missing attributes.

    You have the choice between adding the isNew:false attribute to all objects that doesn't already have this attribute or using a tag.

    You can check the documentation :

    https://www.algolia.com/doc/guides/managing-results/refine-results/filtering/how-to/filter-by-null-or-missing-attributes/