#community-help

Querying Unique Field Values in Typesense

TLDR Sruli asked if Typesense could query unique values in a field. SamHendley clarified that facets could be used for this purpose.

Powered by Struct AI
arrow_up

1

Jan 09, 2023 (11 months ago)
Sruli
Photo of md5-8c57c435e01337c18bf32b8f7749cabf
Sruli
10:52 PM
Hey, not sure if it’s really possible but is there a way for me to query all the different type of values in a given field, for example if I have a collection of books and they each have a topic but there can be 2 books with the same topic and I want to get a list of all the topics, is that something typesense can do or will I need to make another collection for topics?
SamHendley
Photo of md5-a9a351e11d64f05b41fec183816a0cda
SamHendley
10:58 PM
that’s what facets are for
arrow_up

1

10:59
SamHendley
10:59 PM
you can then basically do facet_by=topic&page_size=0&facet_count=10000
Sruli
Photo of md5-8c57c435e01337c18bf32b8f7749cabf
Sruli
10:59 PM
Thank you!!