#community-help

Setting dynamic range faceting in Typesense

TLDR Jacob requested dynamic range faceting in Typesense, and explanation for fetching max/min values. Kishore Nallan clarified pricing bucket sizes were user dependent and explained the stats return as part of facet results.

Powered by Struct AI
Aug 30, 2023 (3 months ago)
Jacob
Photo of md5-c60456339dc3724ba99c3f7ca170d671
Jacob
07:59 AM
A question/feature request regarding range faceting: Is it possible to have the ranges dynamically set by Typesense based on actual values in the db?

We have large number of products in a collection and facet on price to support our filtering tool and to show a small graph of the distribution. However, we don’t want to return an enormous response to the client, so we set max_facet_values to 100, but that is not enough and can cause some really bad behaviour where we (for example) miss the highest/lowest values.

What we want to be able to is to ask Typesense to facet on price and dynamically return X number groups based from the lowest to the highest price.

But even more important to start with, how can we ensure that the lowest AND the highest value is included in the faceting response? Without that our entire filtering functionality breaks down.
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
08:55 AM
Our range faceting currently requires passing fixed ranges in the query. It will be useful for Typensese to do this automatically but the tricky thing is arriving at the bucket sizes. We can find the min and max price but deciding how to split that range into buckets still needs to be a user input.
Jacob
Photo of md5-c60456339dc3724ba99c3f7ca170d671
Jacob
10:46 AM
For us, the best input would be how many buckets we want, and then have typesense just evenly split the totalt range in that number of buckets. But I understand that that’s a feature requst.

However, our urgent problem is the min/max values. The ranges in between is just needed for the graph, but when we’re missing the min/max values the filter-slider ends up lying to our user.

What is the best way for us to retrieve the max/min values for the indexed prices?
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
10:48 AM
Min max during range faceting?
Jacob
Photo of md5-c60456339dc3724ba99c3f7ca170d671
Jacob
11:11 AM
The max/min indexed values. I made the incorrect assumption that they would be included in the faceting result given a large enough max_facet_values.

On our product page we have a range slider where it’s possible to filter on the price range. For that, we need to know what the lower and upper bound should be.
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
11:23 AM
When you facet on integer or float fields, a stats is returned as part of facet results. That's not enough?
Jacob
Photo of md5-c60456339dc3724ba99c3f7ca170d671
Jacob
11:29 AM
Doh! You’re absolutely right. Sorry for wasting your time with that question. Thank you!
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
11:32 AM
No problem!

Typesense

Lightning-fast, open source search engine for everyone | Knowledge Base powered by Struct.AI

Indexed 3015 threads (79% resolved)

Join Our Community

Similar Threads

Improving System Performance and Typesense Query Efficiency

SamHendley was experiencing performance issues with Typesense's large-scale system testing and proposed several improvements. Both Jason and Kishore Nallan addressed the suggestions and corrected some misconceptions. They provided further clarification and recommended upgrades for better performance.

9
12mo

Quick Retrieval of Min, Max, and Median Values from Search Query

Prajjval sought a more efficient way to find the min, max, and median values from a search query result. Jason suggested faceting. However, Prajjval clarified that faceting prolonged document upload due to a data type error, which was later resolved.

6
34mo

Issue with Numerical Faceting in Combination with Group_by

Vamshi encounters issues with numerical faceting when used in conjunction with group_by in Typesense. After a detailed query script, Kishore Nallan identifies this as a bug, encouraging the user to raise a Github issue.

7
3mo

Implementing Histogram Slider with Typesense

em1nos asked about implementing a histogram slider with typesense. James suggested using facets and group by feature. Jason recommended creating a new field for price buckets to achieve the desired output using facet_counts.

1

41
10mo

Understanding Facet Query and Filter By on Typesense

Ricardo needed clarification on using facet_query. Kishore Nallan explained its use alongside `filter_by`, helping Ricardo understand the concepts. The discussion also touched upon how facet_query works with sets of fields and the difference between facet_query and filter_by.

22
33mo