#community-help

Understanding Filtering, Faceting and Their Differences

TLDR Gabe inquired about using a boolean field for filtering, sparking a detailed discussion about the distinctions between filtering and faceting with Jason providing a comprehensive explanation.

Powered by Struct AI

1

1

Jun 24, 2021 (31 months ago)
Gabe
Photo of md5-7aff1bf99393eb318e36513504a16e85
Gabe
05:34 PM
If I want to use a boolean field for filtering do I need to mark it as a facet?
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
05:35 PM
If it's only for filtering (and not to fetch counts), you shouldn't need to set it as a facet
Gabe
Photo of md5-7aff1bf99393eb318e36513504a16e85
Gabe
05:42 PM
cool, thanks!
Jun 25, 2021 (31 months ago)
sonu
Photo of md5-6ade4a341436f96c87480052a1584bf3
sonu
06:06 PM
Jason so is facet only to be set while using filter ?
Gabe
Photo of md5-7aff1bf99393eb318e36513504a16e85
Gabe
06:08 PM
I've always been rather confused by the distinction. This does a decent job of explaining it
06:09
Gabe
06:09 PM
basically if you want to group by a field & get # of results per group of this field then you want to use facets (is how I understand it)
06:10
Gabe
06:10 PM
I think these require facets

1

Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
06:14 PM
> so is facet only to be set while using filter ?
No, you can filter without setting a field as a facet, at least in Typesense. In Algolia, IIRC they require all fields you filter by to also be set as facets.

And you can also facet without using filters.
06:15
Jason
06:15 PM
Gabe's screenshot with the annotation around counts for each value displayed in the filter widget is exactly what faceting will give you - counts of unique values for different fields in the result set
06:17
Jason
06:17 PM
Think of faceting as just a way to count all unique values of the faceted fields, in the result set.
Gabe
Photo of md5-7aff1bf99393eb318e36513504a16e85
Gabe
07:56 PM
I think I finally get it 😅

1