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.

fix(xccode): search the txt extraction family's 'text' field (#1139)

xerj-org35903648c83d
diff --git a/engine/crates/xerj-common/src/xccode/fields.rs b/engine/crates/xerj-common/src/xccode/fields.rs
index 82cada362..d05b933c3 100644
--- a/engine/crates/xerj-common/src/xccode/fields.rs
+++ b/engine/crates/xerj-common/src/xccode/fields.rs
@@ -57,7 +57,7 @@ pub fn resolve_fields(mapping: Option<&Value>) -> Vec<String> {
}
}
}
- let out: Vec<String> = FIELDS
+ let mut out: Vec<String> = FIELDS
.iter()
.filter(|f| {
let base = f.split('^').next().unwrap_or(f);
@@ -65,6 +65,15 @@ pub fn resolve_fields(mapping: Option<&Value>) -> Vec<String> {
})
.map(|s| s.to_string())
.collect();
+ // The plain-text extraction family (`.txt` mirrors, logs) puts record
+ // content in `text`, not `body` — every other family (code, markdown,
+ // adoc) uses `body`. Mapping-gated so the unreadable-mapping fallback
+ // above never grows a field an index may not map (the MULTIMATCH_DEFECT
+ // silent-zero). Found via the zalando G7 1/5: all 25 renamed `.txt`
+ // chapters were invisible to `xerj code` while README.md matched.
+ if present.contains("text") {
+ out.push("text".to_string());
+ }
if out.is_empty() {
vec!["body".to_string()]
} else {
@@ -152,6 +161,21 @@ mod tests {
);
}
+ /// #1139: the `.txt` family's content field is `text` — it joins the
+ /// multi_match list ONLY when an index actually maps it, so the
+ /// unreadable-mapping fallback list above stays exactly FIELDS.
+ #[test]
+ fn text_family_content_joins_only_when_mapped() {
+ let with_text = mapping(&[("i", &["body", "text"], false)]);
+ assert_eq!(
+ resolve_fields(Some(&with_text)),
+ vec!["body".to_string(), "text".to_string()]
+ );
+ // No FIELDS member AND no text -> the ["body"] floor still holds.
+ let thin = mapping(&[("i", &["unrelated"], false)]);
+ assert_eq!(resolve_fields(Some(&thin)), vec!["body".to_string()]);
+ }
+
#[test]
fn capable_discovery_finds_only_semantic_text_indices() {
let m = mapping(&[
diff --git a/engine/crates/xerj-common/src/xccode/render.rs b/engine/crates/xerj-common/src/xccode/render.rs
index d267ed5ff..472ca5156 100644
--- a/engine/crates/xerj-common/src/xccode/render.rs
+++ b/engine/crates/xerj-common/src/xccode/render.rs
@@ -117,9 +117,13 @@ fn render_hit(h: &Value, licences: &HashMap<String, String>, opts: &RenderOpts)
};
let mut out = format!("\n─── {loc} ({shown}{lic_part})\n");
+ // `body` is the content field of every family EXCEPT plain text
+ // (`.txt` mirrors put their passage in `text`) — fall back so those
+ // records render a real passage, not an empty one (#1139).
let body = src
.get("body")
.and_then(Value::as_str)
+ .or_else(|| src.get("text").and_then(Value::as_str))
.unwrap_or("")
.to_string();