#2828·typesense

Query string not re-tokenized per field when using field-level token_separators/symbols_to_index with multiple query_by fields

Author: rscottenCreated Mar 11, 2026Updated Sep 23, 2026
Labelspre-triage

Bug Description

When using field-level token_separators and/or symbols_to_index with multiple query_by fields, Typesense tokenizes the query string once, using the rules of the first (or highest-weighted) field in the query_by list. The query is not re-tokenized when searching subsequent fields that have different tokenization rules.

This causes a significant reduction in hit count on lower-ranked fields when the first field's tokenization rules are incompatible with how those fields were indexed.

The v30.1 release notes reference a fix for "query sub-tokenization to respect field-level symbols_to_index and token_separators configuration" — but the bug is still present in v30.1 when mixing fields with different tokenization configs in a single query_by.

Steps to Reproduce

1. Create a collection with two fields that have different tokenization rules:

bash
curl -X POST http://localhost:8108/collections \
  -H "X-TYPESENSE-API-KEY: xyz" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "products",
    "fields": [
      {
        "name": "sku",
        "type": "string",
        "symbols_to_index": ["-"],
      },
      {
        "name": "title",
        "type": "string",
        "token_separators": ["-", ".", "/"]
      }
    ]
  }'

2. Index two documents:

bash
curl -X POST "http://localhost:8108/collections/products/documents/import" \
  -H "X-TYPESENSE-API-KEY: xyz" \
  -H "Content-Type: text/plain" \
  -d '{"id":"1","sku":"ABC-1234","title":"Vintage Wooden Chair"}
{"id":"2","sku":"XYZ-5678","title":"Mid-Century Modern Steel Desk"}'

3. Search with sku as the first query_by field:

bash
curl "http://localhost:8108/collections/products/documents/search" \
  -H "X-TYPESENSE-API-KEY: xyz" \
  -G \
  --data-urlencode "q=wooden" \
  --data-urlencode "query_by=sku,title"

Expected Behavior

"Vintage Wooden Chair" (document 1) should be returned because "wooden" matches the title field. The query "wooden" contains no characters in sku's token_separators, so its tokenization is neutral — but even with a query like "wooden-desk", the title field should be searched using its own tokenization rules (no splitting on -), not sku's.

Actual Behavior

Searching query_by=sku,title returns fewer results than searching query_by=title alone for the same query. The query string is tokenized using sku's token_separators and symbols_to_index rules, and those tokens are then used verbatim when searching title — which was indexed without those separators.

This is demonstrable by running these two searches and comparing found:

bash
# Search 1: sku first
curl "...?q=wooden-desk&query_by=sku,title"

# Search 2: title only
curl "...?q=wooden-desk&query_by=title"

Search 1 returns fewer results than Search 2 because "wooden-desk" is split into ["wooden", "desk"] by sku's - separator, and those tokens are then used against title — which indexed "wooden-desk" as a single token.

Root Cause (Hypothesis)

Typesense appears to perform a single query tokenization pass before fanning the search out across query_by fields. The tokenization uses the rules of the first field in the list. Correct behavior would be to re-tokenize the query independently for each field, using that field's own token_separators and symbols_to_index configuration.

Impact

This makes field-level token_separators and symbols_to_index — introduced in v28 and present in v30.1 — effectively unusable in practice for any schema that mixes identifier fields (e.g., SKUs, part numbers, barcodes) with natural-language fields (e.g., title, description, tags) in a single query_by.

Workaround Attempted

Using multiSearch with the query_by fields split across two separate searches avoids the tokenization bleed. However, this workaround is blocked by the fact that union mode does not support facet_by (see related issue #2829), making it impractical for real-world search UIs that require faceted navigation.

Environment

  • Typesense version: 30.1
  • Deployment: Typesense Cloud
  • OS: macOS
  • Client library & version: typesense-js v1.3.0