typesense / typesense/typesense
[Feature Request] Dynamic facet filtering based on occurrence frequency
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 26.6k
- Forks
- 973
- Avg merge
- 18h 45m
- Merged PRs (30d)
- 4
Description
Describe your feature request
Add support for filtering facets based on their occurrence ratio within the search results, with a configurable parameter (e.g., dynamic_facet_min_occurrence_ratio).
Introduce two types of facet configurations:
static facets– always returned regardless of their occurrence ratio. Always first in the facet results.dynamic facets– only returned if they meet the occurrence ratio threshold. Sorted by frequency within the results.
Please describe your use-case for the feature request
We are implementing an e-commerce search. Our product catalogs usually have hundreds of different properties, many of which are only relevant to small subsets of products.
Without filtering, the search response often returns too many facets, cluttering the UI. For example, searching for "shoes" might return facets for unrelated product attributes like "battery_capacity" or "screen_size", even though only few products on the 20th page of the search results have these properties.
We want to always display certain static facets first (e.g., "brand", "price") while dynamically filtering other facets so that only those appearing in at least a certain percentage of results (e.g., 50%) are displayed.
Describe alternatives you've considered
Currently, we handle this post-search by adding an interceptor service between the UI and Typesense.
Additional context
This feature could extend the search API with parameters like:
{
"facet_by": "brand,price",
"facet_by_dynamic": "*",
"dynamic_facet_min_occurrence_ratio": 0.5
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No source file, test, or entry point is named. Start by locating the search API's facet-processing code and existing facet tests, then compare the requested static and dynamic configuration with current behavior; done means occurrence-ratio filtering and the requested facet ordering are implemented and tested.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- backend, search
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100