Checkbox which shows only the objects where this attribute isn't NULL

Hi I would like to do a refinement list but for one attribute, I explain : If I click on the checkbox it shows only the objects where this attribute isn’t NULL. How Can I Do that ? Thanks a lot :slight_smile:

Hey Victos,

We don’t have faceting on null as a value in our featureset, but what you can do is when indexing, index the null values with another attribute is_defined: false, then you can use filters: 'is_defined:true, or whatever other naming makes sense for you. The other records will have is_defined:true

Does that help you?

1 Like

Hi ! Thanks for responding so I created a variable thanks to scout and it worked !!! But just a simple question How can I change the name ? Because now I have True and False as name .

You can use a ternary for that, depending on what you’re toggling:

$is_defined = $maybe_defined_attribute ? 'value-for-true' : 'value-for-false';

Then you can filter on filters: 'is_defined:value-for-true'

1 Like

It worked thank you !! :slight_smile:

With pleasure :smile:

1 Like