Slower faceting + group by after refactor
Author: lazkaCreated May 15, 2025Updated Sep 23, 2026
Labelsbugfeature:faceting
From what I understood only total_values should be wrong in case top_values kicks in (??), but I also get wrong facet "counts", as if it doesn't understand grouping and counts every hit in the group separately. In my case this leads to 10x inflated facet counts for some fields.
Maybe I'm missing something though.
Minimal example:
Schema:
{
"name": "menu",
"fields": [
{"name": "name", "type": "string", "facet": true},
{"name": "groupId", "type": "string"}
]
}Documents:
[
{
"name": "foo",
"groupId": "1"
},
{
"name": "foo",
"groupId": "1"
}
]Query:
{
"q": "*",
"page": 1,
"per_page": 0,
"facet_by": "name",
"group_by": "name",
"facet_strategy": "top_values"
}Expected (count=1):
"facet_counts": [
{
"counts": [
{
"count": 1,
"highlighted": "foo",
"value": "foo"
}
],
"field_name": "name",
"sampled": false,
"stats": {
"total_values": 1
}
}
]Actual (count=2):
"facet_counts": [
{
"counts": [
{
"count": 2,
"highlighted": "foo",
"value": "foo"
}
],
"field_name": "name",
"sampled": false,
"stats": {
"total_values": 1
}
}
]Source: typesense/typesense