#community-help

Clarification on Faceting and Grouping in Typesense

TLDR Carlo asked about faceting and grouping in Typesense. Kishore Nallan clarified their operation, suggesting they account for grouping while calculating on the whole set.

Powered by Struct AI

1

Oct 17, 2023 (1 month ago)
Carlo
Photo of md5-749f5f0254cb5678484efd4f599a4a25
Carlo
08:48 AM
What kind of query should I look at to get, grouped on a specific field, the min/max and count for a given value?
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
01:53 PM
You have to use facet _by

1

Oct 23, 2023 (1 month ago)
Carlo
Photo of md5-749f5f0254cb5678484efd4f599a4a25
Carlo
07:35 AM
one followup if you don't mind. Facets and summaries seem to be always done on the full result set, not on the grouping itself. But maybe grouping is not what I'm looking for in the first place.
I have 15k records, which have a field "owner" which has ~ 1000 distinct values. I want the top 1, grouped by this owner, and then get the facet values based on this, but from what I read here:
https://threads.typesense.org/kb/t/grouping-and-aggregation-in-typesense/2K62a0
facets are always running before grouping, not after. Is there a way to get faceted search running on the grouped resultset? (or an alternative way to do this)
Oct 24, 2023 (1 month ago)
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
09:57 AM
That answer is a bit misleading. The facets are calculated on the whole set but the faceting takes grouping into account. So for e.g. if there are N groups containing K records the counts will be tracking N and not K. Maybe it it's not working as expected maybe you can show an example with just 4-5 example records.