fix(fts): remove NEAR from infix operator list
NEAR is an FTS5 function (NEAR(term1 term2, N)), not an infix operator like AND/OR/NOT. Passing it through unquoted in Safe mode was incorrect - it would be treated as a literal term rather than a function call. Users who need NEAR proximity search should use FtsQueryMode::Raw which passes the query through verbatim to FTS5. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -54,7 +54,9 @@ pub fn to_fts_query(raw: &str, mode: FtsQueryMode) -> String {
|
|||||||
|
|
||||||
// FTS5 boolean operators are case-sensitive uppercase keywords.
|
// FTS5 boolean operators are case-sensitive uppercase keywords.
|
||||||
// Pass them through unquoted so users can write "switch AND health".
|
// Pass them through unquoted so users can write "switch AND health".
|
||||||
const FTS5_OPERATORS: &[&str] = &["AND", "OR", "NOT", "NEAR"];
|
// Note: NEAR is a function NEAR(term1 term2, N), not an infix operator.
|
||||||
|
// Users who need NEAR syntax should use FtsQueryMode::Raw.
|
||||||
|
const FTS5_OPERATORS: &[&str] = &["AND", "OR", "NOT"];
|
||||||
|
|
||||||
let mut result = String::with_capacity(trimmed.len() + 20);
|
let mut result = String::with_capacity(trimmed.len() + 20);
|
||||||
for (i, token) in trimmed.split_whitespace().enumerate() {
|
for (i, token) in trimmed.split_whitespace().enumerate() {
|
||||||
|
|||||||
Reference in New Issue
Block a user