Skip to content

[breaking] Remove the whitespace heuristic in From<String> for MatchValue; add Condition::matches_keyword - #314

Open
agourlay wants to merge 1 commit into
devfrom
remove-string-matchvalue-heuristic
Open

agourlay wants to merge 1 commit into
devfrom
remove-string-matchvalue-heuristic

Conversation

@agourlay

@agourlay agourlay commented Nov 11, 2026 •

Copy link
Copy Markdown
Member

From<String> for MatchValue picks the match type from the value: a string with whitespace becomes a full-text Text match, anything else an exact Keyword. So Condition::matches("color", "Light Orange".to_string()) silently sends a different filter than "Orange". This bit bfb's dataset mode (qdrant/bfb#193).

This PR removes the conversion and adds Condition::matches_keyword, so callers pick matches_keyword or matches_text explicitly. A compile_fail doc test pins it. The other conversions are unchanged.

Breaking: Condition::matches(field, some_string) no longer compiles. Use matches_keyword(field, "..."), which is what whitespace-free values already got. #86 tried making the conversion always Keyword and reverted it for compatibility; a compile error is safer than a silent change. The qdrant/api-reference Rust snippets need the same update.

Tested: build, fmt, clippy -D warnings, 119 doc tests. Integration tests are left to CI.

🤖 Generated with Claude Code

The conversion picked the match type from the value's content: a String
with whitespace became MatchValue::Text, a full-text match, and any other
became MatchValue::Keyword, an exact match. Condition::matches("color",
"Light Orange".to_string()) therefore sent a different filter than
Condition::matches("color", "Orange".to_string()), with nothing at the
call site to say so.

Remove the conversion, so a single string has to name its match:
Condition::matches_keyword for an exact keyword (new, alongside the
existing matches_text, matches_phrase, matches_prefix, ...) or
Condition::matches_text for full text. A compile_fail doc test pins that
Condition::matches no longer takes a String. The other conversions (bool,
i64, Vec<i64>, Vec<String>, [&str; N]) are unchanged.

Callers in docs, tests and snippets move to matches_keyword, and the
integration test asserting the whitespace heuristic is removed; the
matches_text assertion next to it still covers full-text matching.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@agourlay agourlay changed the title Remove the whitespace heuristic in From<String> for MatchValue; add Condition::matches_keyword [breaking] Remove the whitespace heuristic in From<String> for MatchValue; add Condition::matches_keyword Nov 12, 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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant