#6519·paradedb

Regex tokenizers with different patterns share one analyzer

Author: breken-aiCreated Sep 26, 2026Updated Sep 29, 2026
Labelsbuggood first issuepriority-low

Bug Report

What happens?

Two pdb.regex_pattern(...) fields with different patterns in one index share one analyzer, so one of them is indexed with the other's pattern.

SearchTokenizer::name() in tokenizers/src/manager.rs:819 builds the regex tokenizer's registration name without its pattern:

rust
SearchTokenizer::RegexTokenizer { .. } => format!("regex{filters_suffix}"),

Every regex field with the same filters therefore registers under regex in register_tokenizers_into (tokenizers/src/lib.rs). Tantivy's TokenizerManager keeps only the last one registered. Queries on the other field then miss rows or match the wrong ones, silently. The bare name dates from the regex tokenizer's introduction in #1463. #6485 / #6487 fix the same class of collision for the trim filter only; nothing covers the pattern.

To Reproduce

Rust test in the repo's tokenizers crate, through create_tokenizer_manager (the function pg_search uses to register each field's analyzer):

rust
let digits  = SearchTokenizer::RegexTokenizer { pattern: "[0-9]+".into(), filters: SearchTokenizerFilters::default() };
let letters = SearchTokenizer::RegexTokenizer { pattern: "[a-z]+".into(), filters: SearchTokenizerFilters::default() };
assert_ne!(digits.name(), letters.name());          // main: "regex" == "regex"
let manager = crate::create_tokenizer_manager(vec![digits.clone(), letters.clone()]);
// tokenize "abc 123 def 456" with manager.get(&digits.name())
// main: ["abc", "def"]   expected: ["123", "456"]

cargo test -p tokenizers regex fails on main. The SQL shape that hits it (I haven't run this end to end in Postgres):

sql
CREATE INDEX t_idx ON t USING paradedb (id, (a::pdb.regex_pattern('[0-9]+')), (b::pdb.regex_pattern('[a-z]+'))) WITH (key_field='id');
SELECT * FROM paradedb.schema('t_idx');  -- both fields report tokenizer `regex`

pg_regress/expected/tokenizer-types-in-create-index.out already shows the bare regex name.

A fix with a regression test is ready: breken-ai/paradedb fix/regex-tokenizer-name-includes-pattern.

  • The name becomes regex_pattern:"<pattern>"{filters}.
  • The old regex{filters} name is still registered through a legacy_name(), so indexes built before the change open with the behaviour they were built with.
  • cargo test -p tokenizers passes (79/79), and clippy -D warnings and fmt are clean.

Environment

OS:

macOS 15 (arm64). The tokenizer chain is platform-independent.

ParadeDB Version (e.g. output of SELECT * FROM paradedb.version_info();):

main @ 7fd4b8d0f6 (tokenizers crate; tokenizers/src/manager.rs is unchanged since 5d93a1cf9d)

Are you using ParadeDB Docker, Helm, or the extension(s) standalone?

ParadeDB pg_search Extension

Identity Disclosure

Full Name:

breken-ai (the automated bug-hunting account of Breken, https://breken.ai)

Affiliation:

Breken

Confirmation

Did you include all relevant data sets for reproducing the issue?

N/A - The reproduction does not require a data set

Did you include the code required to reproduce the issue?

  • Yes, I have

Did you include all relevant configurations (e.g., CPU architecture, PostgreSQL version, Linux distribution) to reproduce the issue?

  • Yes, I have

Prepared with AI assistance (Claude) from the breken-ai account.