Skip to content

armgit / xerj

Public Imported from GitHub
0

AI search engine and MCP server for bots and agents. One Rust binary indexes code, docs, logs, JSONL/CSV and PDFs for BM25 full-text, vector and hybrid search, code search without grep, agent memory and RAG. Elasticsearch-compatible API; Corpus Hub serves hundreds of reference memory corpora.

feat(query): #668 thread a case_insensitive flag through QueryNode::Wildcard (plumbing)

xerj-org8034be6716ae
diff --git a/engine/crates/xerj-engine/src/index.rs b/engine/crates/xerj-engine/src/index.rs
index 94a33fa93..1e5265ac3 100644
--- a/engine/crates/xerj-engine/src/index.rs
+++ b/engine/crates/xerj-engine/src/index.rs
@@ -32634,6 +32634,7 @@ mod lexically_typeless_lowering_tests {
value: "0*".into(),
boost: None,
constant_score: true,
+ case_insensitive: false,
},
QueryNode::Match {
field: "emb".into(),
@@ -33765,11 +33766,13 @@ fn strip_nested_path_in_query(q: &QueryNode, path: &str) -> QueryNode {
value,
boost,
constant_score,
+ case_insensitive,
} => QueryNode::Wildcard {
field: strip(field),
value: value.clone(),
boost: *boost,
constant_score: *constant_score,
+ case_insensitive: *case_insensitive,
},
QueryNode::Exists { field } => QueryNode::Exists {
field: strip(field),
@@ -41049,6 +41052,7 @@ fn query_node_to_fts_with_keyword_fields(
value,
boost,
constant_score,
+ case_insensitive: _,
} => {
// `wildcard` on a KEYWORD field: expand the keyword FST term
// dictionary to every term matching the pattern (`*`=0+ chars,
@@ -42415,6 +42419,7 @@ fn scored_fast_plan(
value,
boost,
constant_score: true,
+ case_insensitive: _,
} if fs.kw.contains(field) => Some(ScoredPlan::Filtered {
filter: vec![ScoredFilterLeaf::KeywordWildcard {
field: field.clone(),
@@ -44336,6 +44341,7 @@ mod fts_projection_tests {
value: "run*".into(),
boost: None,
constant_score: true,
+ case_insensitive: false,
};
match query_node_to_fts(&q, &tf, &kw(&[])).expect("text wildcard projects") {
FtsQuery::Wildcard(w) => {
diff --git a/engine/crates/xerj-engine/src/sql.rs b/engine/crates/xerj-engine/src/sql.rs
index a8323e518..6c293f489 100644
--- a/engine/crates/xerj-engine/src/sql.rs
+++ b/engine/crates/xerj-engine/src/sql.rs
@@ -638,6 +638,7 @@ fn parse_condition(tokens: &[Token], pos: &mut usize, depth: usize) -> Result<Qu
value: pattern,
boost: None,
constant_score: false,
+ case_insensitive: false,
}
}
"not_like" => {
@@ -655,6 +656,7 @@ fn parse_condition(tokens: &[Token], pos: &mut usize, depth: usize) -> Result<Qu
value: pattern,
boost: None,
constant_score: false,
+ case_insensitive: false,
}],
minimum_should_match: None,
}
diff --git a/engine/crates/xerj-query/src/ast.rs b/engine/crates/xerj-query/src/ast.rs
index eff672f60..5e7434a2f 100644
--- a/engine/crates/xerj-query/src/ast.rs
+++ b/engine/crates/xerj-query/src/ast.rs
@@ -369,6 +369,13 @@ pub enum QueryNode {
/// `term{case_insensitive}` / query_string lowerings that keep BM25.
#[serde(default, skip_serializing_if = "is_false")]
constant_score: bool,
+ /// #668: fold case on both sides when matching a KEYWORD field. `false`
+ /// (default) = ES-correct case-sensitive keyword wildcard. `true` is set
+ /// only for the `term{case_insensitive:true}` → Wildcard rewrite (and
+ /// query_string lowerings), which rely on the matcher folding case.
+ /// Ignored for `text` fields (analysed-token semantics apply regardless).
+ #[serde(default, skip_serializing_if = "is_false")]
+ case_insensitive: bool,
},
/// Matches documents where the field has any non-null value.
diff --git a/engine/crates/xerj-query/src/parser.rs b/engine/crates/xerj-query/src/parser.rs
index 2b6f78b2a..563e526b0 100644
--- a/engine/crates/xerj-query/src/parser.rs
+++ b/engine/crates/xerj-query/src/parser.rs
@@ -1040,6 +1040,7 @@ fn parse_term(params: &Value) -> Result<QueryNode> {
// threading `case_insensitive` through
// QueryNode::Wildcard into the columnar/FST arms.
constant_score: false,
+ case_insensitive: true,
};
return Ok(maybe_named(node, name));
}
@@ -1288,6 +1289,7 @@ fn parse_wildcard(params: &Value) -> Result<QueryNode> {
value: value.to_string(),
boost: None,
constant_score: true,
+ case_insensitive: false,
});
}
@@ -1306,6 +1308,10 @@ fn parse_wildcard(params: &Value) -> Result<QueryNode> {
value,
boost,
constant_score: true,
+ case_insensitive: inner
+ .get("case_insensitive")
+ .and_then(|v| v.as_bool())
+ .unwrap_or(false),
})
}
@@ -2107,6 +2113,7 @@ fn parse_qs_unary(toks: &[QsTok], pos: &mut usize, ctx: QsFields<'_>) -> Option<
value: lowered.clone(),
boost,
constant_score: true,
+ case_insensitive: true,
})
.collect(),
);