Distinct values for number facets
Problem Description
I am building a facet filter UI that gets populated by the facets property returned from search results. The current API for dealing with number facets forces you to make assumptions about the data by supplying one or more ranges :
{
count: 3, // Total number of ranges
values: {
'0-3': 5, // Number of documents that have a value between 0 and 3 (inclusive)
'3-7': 15, // Number of documents that have a value between 3 and 7 (inclusive)
'7-10': 80, // Number of documents that have a value between 7 and 10 (inclusive)
}
}This API assumes that I know what kind of number ranges I'm dealing with ahead of time. In my case, there is a large set of facets with potentially wildly varying ranges. Instead, I'd like to be able to reason about each distinct number value without having to supply any ranges. It'd be preferable if the results looked like enums :
{
count: 5, // Total number of distinct number values
values: { // Object keys are number values, object values are counts.
2: 3,
3: 2,
5: 15,
8: 75,
9: 5
}
}Proposed Solution
Allow for the same kind of configurations that are valid for enums. i.e either an empty object or this:
| Property | Type | Default | Description |
|---|---|---|---|
size |
number |
10 |
`Number of values to return. |
order |
string |
DESC |
Order of the values. Can be either ASC or DESC. |
limit |
number |
100 |
Maximum number of values to consider. |
offset |
number |
0 |
Number of values to skip. |
Alternatives
I've considered just representing my numbers as enum in my schema instead, but this gets very awkward as I'd still like to be able to use number operators when filtering on the facets.
Additional Context
No response
Source: oramasearch/orama