typesense / typesense/typesense
multiSearch union mode does not support facet_by, making it an impractical workaround for per-field tokenization issues
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 26.6k
- Forks
- 973
- Avg merge
- 18h 45m
- Merged PRs (30d)
- 4
Description
Bug Description
multiSearch with union: true does not return facet counts when facet_by is included in one or more of the search requests. This makes union mode unusable as a workaround for the per-field tokenization bug (see related issue #2828 ) for any application that requires faceted navigation.
Steps to Reproduce
curl -X POST "http://localhost:8108/multi_search" \
-H "X-TYPESENSE-API-KEY: xyz" \
-H "Content-Type: application/json" \
-d '{
"union": true,
"searches": [
{
"collection": "products",
"q": "wooden chair",
"query_by": "sku,skus,storageLocation",
"facet_by": "_tags,colors",
"max_facet_values": 100
},
{
"collection": "products",
"q": "wooden chair",
"query_by": "title,description",
"facet_by": "_tags,colors",
"max_facet_values": 100
}
]
}'
Expected Behavior
The unified result should include facet_counts populated from the merged result set, respecting the facet_by parameter passed in the first search request.
Actual Behavior
facet_counts is absent in the union response. Facets are not returned regardless of which search in the array carries the facet_by parameter.
Impact
The intended use case for splitting fields across multiple multiSearch requests is to work around the query tokenization bug described in #2828 — where fields with different token_separators/symbols_to_index configs corrupt each other's token sets when combined in a single query_by. The multi-search split resolves the tokenization problem but breaks faceted search, which is a non-starter for most production search UIs.
The net result is that there is currently no viable workaround for the tokenization bug in applications that use facets.
Possible Resolution
Either:
- Support
facet_byin union mode, aggregating facet counts across the merged result set, or - Fix the underlying per-field tokenization bug (issue #2828), eliminating the need for the multi-search workaround entirely.
Environment
- Typesense version: 30.1
- Deployment: Typesense Cloud
- Client library & version:
typesense-js v1.3.0
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
Start by reproducing the POST /multi_search request from the issue with union: true, facet_by, and max_facet_values. Trace the union response handling and verify how facet_counts are produced. Done means the unified response includes facet_counts aggregated from the merged result set while respecting facet_by from the first search request.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- backend-api-design, search
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100