diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/search/native.rs | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/src/search/native.rs b/src/search/native.rs index a7b2fb5..665477a 100644 --- a/src/search/native.rs +++ b/src/search/native.rs @@ -267,7 +267,7 @@ mod tests { #[test] fn boolean_prefixes_parse_to_exact_index_terms() { let mut qp = build_query_parser(); - let terms = |query: &str| -> std::collections::BTreeSet<String> { + let mut terms = |query: &str| -> std::collections::BTreeSet<String> { qp.parse_query_checked::<&str>(query, None, None) .unwrap_or_else(|e| panic!("{query} must parse: {e:?}")) .unique_terms() @@ -288,21 +288,29 @@ mod tests { assert!(terms("chr:1").contains("XC1")); assert!(terms("peakchr:1").contains("XPC1")); // search.py:204-209, 222-223: group values lowercase (xapian - // does not stem boolean fields starting with a capital). + // does not stem boolean fields starting with a capital): + // B6 -> b6, concatenated behind XG. (The r1-test G4 smoke's + // XGbxd was the same rule for value BXD, not a stem.) let b6 = terms("group:B6"); - assert!(b6.contains("XGbxd"), "group:B6 must lowercase to XGbxd, got {b6:?}"); - assert!(!b6.contains("XGBXD"), "group must not emit the raw-case term"); + assert!( + b6.contains("XGb6"), + "group:B6 must lowercase to XGb6, got {b6:?}" + ); + assert!(!b6.contains("XGB6"), "group must not emit the raw-case term"); } /// The probabilistic-prefix registrations (C3.3): description, rif, /// wiki and the uppercase aliases must parse as weighted field /// terms, not free text (search.py:229-233). With STEM_ALL_Z the - /// field term is the prefix + Z-stemmed value (e.g. XDZinsulin), - /// so assert on the prefix, the invariant the registration owns. + /// field term is Z+<prefix>+stem — ZXDinsulin, ZXRF…, ZXWK… — the + /// exact shape the production indexer's TermGenerator emits for + /// these fields (confirmed against the dev index: term + /// ZXWKdiabet exists with 24 gene documents, ZXRF-prefixed terms + /// abound; d.v. the delve probes in LANE-REPORT). #[test] fn probabilistic_prefixes_and_aliases_parse_as_field_terms() { let mut qp = build_query_parser(); - let prefixed = |query: &str, prefix: &str| { + let mut prefixed = |query: &str, prefix: &str| { let set = qp .parse_query_checked::<&str>(query, None, None) .unwrap_or_else(|e| panic!("{query} must parse: {e:?}")) @@ -311,11 +319,11 @@ mod tests { .collect::<std::collections::BTreeSet<_>>(); set.iter().any(|t| t.starts_with(prefix)) }; - assert!(prefixed("description:insulin", "XD")); - assert!(prefixed("rif:insulin", "XRF")); - assert!(prefixed("RIF:insulin", "XRF")); - assert!(prefixed("wiki:diabetes", "XWK")); - assert!(prefixed("WIKI:diabetes", "XWK")); + assert!(prefixed("description:insulin", "ZXD")); + assert!(prefixed("rif:insulin", "ZXRF")); + assert!(prefixed("RIF:insulin", "ZXRF")); + assert!(prefixed("wiki:diabetes", "ZXWK")); + assert!(prefixed("WIKI:diabetes", "ZXWK")); } /// The index-open guards, without touching a real index. |
