typesense / typesense/typesense

multiSearch union mode does not support facet_by, making it an impractical workaround for per-field tokenization issues

Open
#2,829 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

pre-triage
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:

  1. Support facet_by in union mode, aggregating facet counts across the merged result set, or
  2. 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.