Hi everyone, I have a question regarding facets in...
# community-help
a
Hi everyone, I have a question regarding facets in Typesense. We’re working with a fairly large dataset where some facet fields contain a significant number of values. To improve performance, we’re considering caching these facet values. However, while implementing this, we ran into the
max_facet_values
limitation. We understand that this can be increased to a very large number, but that doesn’t feel like the most efficient or scalable approach. Is there a recommended way to retrieve all facet values (or all values for a specific facet field) without relying on a very high
max_facet_values
setting? Or is there a best practice for handling/caching large facet sets in Typesense? Any guidance or suggestions would be greatly appreciated! Thanks in advance 🙂
f
Hey @Antoon , At the moment, there isn't a separate API in Typesense for paging through or fully enumerating facet values outside of max_facet_values. Faceting in Typesense is designed mainly for search UI use cases, where you want the top facet values for the current result set, not a complete export of every value in a high- cardinality field. Because of that, max_facet_values is the mechanism that controls how many values are returned, and there isn't another built-in path to give all facet values, but paginate them separately. For fields with very large numbers of unique values, making max_facet_values very large is usually not the best approach. It will increase response size and it's not really the pattern the facet system is optimized around. If the goal is to let users explore a large facet, the better pattern is usually to keep max_facet_values at a reasonable level and use facet_query so users can search within that facet instead of loading the entire set upfront. If your requirement is to cache or retrieve the full set of values for a facet field, you could handld that outside the main faceting response path by maintaining that list in your application layer, or in a separate collection that is specifically meant for facet value lookup. That should scale much better