Skip to content

Add datadog_v2 tokenizer with dot-separated parts - #6922

Open
PSeitz wants to merge 2 commits into
quickwit-oss:mainfrom
PSeitz:better_tokenizer
Open

PSeitz wants to merge 2 commits into
quickwit-oss:mainfrom
PSeitz:better_tokenizer

Conversation

@PSeitz

@PSeitz PSeitz commented Oct 22, 2026

Copy link
Copy Markdown
Collaborator

Summary

Add datadog_v2 so dotted names can be searched by their individual parts as well as their complete token. Numeric dotted values, such as IP addresses and decimals, stay whole.

Changes

  • Register datadog_v2, using Unicode word boundaries and emitting each original token followed by its dot-separated parts.
  • Assign consecutive positions to the parts, with the original token spanning those positions.
  • Apply lowercasing and the existing token-length limit to each emitted token.
  • Document configuration and add tests for offsets, positions, Unicode, numeric exceptions, punctuation, and analyzer filters.

Examples:

Input Tokens
Foo.Bar.Baz foo.bar.baz, foo, bar, baz
v1.2.3 v1.2.3, v1, 2, 3
192.168.1.1 192.168.1.1
32.3 32.3

Adoption

Opt in with tokenizer: datadog_v2. Existing datadog behavior stays unchanged. Existing documents need reindexing to gain the additional tokens. Dotted nonnumeric tokens produce additional postings, increasing index size.

Verification

  • make fmt — passed.
  • cargo nextest run -p quickwit-query — all 188 tests passed.
  • git diff --check — passed.
  • End-to-end indexing/search and performance benchmarks have not been run.

@PSeitz
PSeitz requested a review from a team as a code owner October 22, 2026 10:25
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-22T14:13:34.144113Z 438a121 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

https://github.com/quickwit-oss/quickwit/blob/4b0b29c442503c18e6a4ef6124529f81a2089d95/quickwit-query/src/tokenizers/datadog_v2.rs#L81-L82
P2 Badge Handle the token graph before building dotted prefix queries

When datadog_v2 analyzes a dotted prefix, this emits the whole token first and queues its parts, so the final emitted token is only the last part. PhrasePrefixQuery::get_terms forwards that flat order and build_tantivy_ast_impl makes the last term the prefix (quickwit-query/src/query_ast/phrase_prefix_query.rs:66-71,148-150), while dropping position_length. Thus, on a datadog_v2 field containing foo.bar, an ES match_phrase_prefix or quoted prefix query for foo.ba requires exact foo.ba and foo terms and only expands ba, so it cannot match foo.bar even though the preserved whole token has the requested prefix. Prefix-query construction needs to account for this token graph rather than treating every emitted token as one phrase path.

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 438a121f73

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

return Ok(self.zero_terms_query.into());
}
if terms.len() == 1 {
if terms.len() == 1 && !matches!(self.mode, FullTextMode::BoolPrefix { .. }) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Lift the cap for single-term bool prefixes

For a datadog_v2 field, a dotted prefix such as foo.ba is reduced to one term by collect_terms, so this new condition routes it into the branch that calls set_max_expansions(max_expansions). The ES match_bool_prefix conversion supplies 50 (elastic_query_dsl/match_bool_prefix.rs:38), even though FullTextMode documents that value as a fuzzy limit rather than a prefix-range limit; consequently, when more than 50 indexed dotted terms share the prefix, Tantivy expands only 50 and silently omits matching documents. Lift the cap for this one-term case just as PhrasePrefixQuery::get_terms does.

Useful? React with 👍 / 👎.

| `chinese_compatible` | Chop between each CJK character in addition to what `default` does. Should be used with `record: position` to be able to properly search |
| `lowercase` | Applies a lowercase transformation on the text. It does not tokenize the text. |
| `datadog`, `unicode_segmenter` | Splits at Unicode word boundaries, lowercases tokens, and applies the 255-byte token-length limit. |
| `datadog_v2` | Like `datadog`, plus dot-separated parts: `Foo.Bar` → `foo.bar`, `foo`, `bar`. Numeric dotted tokens such as `192.168.1.1` and `32.3` stay whole. |

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Document datadog_v2 for JSON fields

datadog_v2 is also accepted for JSON string values because validate_fields_tokenizers looks up JsonObject tokenizers in the same manager (quickwit/quickwit-doc-mapper/src/doc_mapper/doc_mapper_impl.rs:366-372), but the JSON-field table later on this page still says the only choices are raw, default, en_stem, and chinese_compatible (line 379). This leaves the public configuration documentation internally contradictory and tells users that the new tokenizer cannot be used for JSON or dynamic mappings; update that explicit list or point it to the shared tokenizer table.

AGENTS.md reference: AGENTS.md:L23-L24

Useful? React with 👍 / 👎.

@dayaffe dayaffe added area:doc-mapping Index schema, field types, tokenizers, date formats type:feature A new capability, such as an endpoint, query type, source, setting or command labels Oct 22, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:doc-mapping Index schema, field types, tokenizers, date formats type:feature A new capability, such as an endpoint, query type, source, setting or command

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants