Include a NULL option in a Refinement List

We have a use case where a null value is a legitimate value for a field. To simplify, let’s say that some products don’t have a category.

When displaying a refinement list based on Category facet, I would like to have an entry in the list that corresponds to a null value, ideally with an informative label, e.g. “(No Cetegory)” of “(Not specified)”.

Is this possible?

Thanks!

Hi @aaron.edwards,

Thanks for contacting Algolia! The Algolia engine does not filter or recognize null or missing attributes/values. Algolia always requires a value to hook into.

In this instance, you would have to include an actual string value "null" on indexing so that Algolia can recognize it.

Although this is not exactly the same, this FAQ further describes how Algolia needs a value or boolean: https://www.algolia.com/doc/guides/managing-results/refine-results/filtering/how-to/filter-by-null-or-missing-attributes/

I hope this provides guidance on how you can achieve your goal of a “no category” or “not specified” value.

I guess we can just convert null to “null” when we index.

Thanks for the quick reply.

1 Like