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.
Rust agent-memoryai-agentsbm25claude-codeclicode-searchcursordatabaseelasticsearchfull-text-searchhybrid-searchjsonllocal-firstmcpmcp-servermodel-context-protocolragrustsearch-enginevector-search
fix(es-compat): _field_caps fields filter honors full globs (#853) (#854)
xerj-orgbb550a2b7280
diff --git a/engine/crates/xerj-api/src/es_compat.rs b/engine/crates/xerj-api/src/es_compat.rsindex 32ca2ed4a..c3a538efa 100644--- a/engine/crates/xerj-api/src/es_compat.rs+++ b/engine/crates/xerj-api/src/es_compat.rs@@ -3212,14 +3212,6 @@ fn apply_get_doc_source_filter(source: Value, params: &GetDocParams) -> Value {xerj_engine::filter_object(&source, &includes, &excludes)}-fn source_field_matches(field: &str, pattern: &str) -> bool {- if let Some(prefix) = pattern.strip_suffix('*') {- field.starts_with(prefix)- } else {- field == pattern- }-}-#[cfg(test)]mod get_doc_source_filter_tests {use super::*;@@ -22151,7 +22143,7 @@ fn register_field_cap_entry(let matches = fields_filter == "*"|| fields_filter.split(',')- .any(|f| source_field_matches(&dotted_name, f.trim()));+ .any(|f| glob_match(f.trim(), &dotted_name));if matches {let native_es_type = native_type_to_es_str(&field.field_type);let es_type = declared_flattened_type(properties, &dotted_name)@@ -22454,7 +22446,7 @@ pub async fn field_caps(if fields_filter != "*" {let matches = fields_filter.split(',')- .any(|f| source_field_matches(&name, f.trim()));+ .any(|f| glob_match(f.trim(), &name));if !matches {continue;}@@ -22761,6 +22753,51 @@ mod flat_object_field_caps_tests {);}+ // #853: `_field_caps?fields=<pattern>` must honor FULL globs (`*` anywhere),+ // like ES — the old trailing-`*`-only matcher dropped a leading/mid glob, so+ // `fields=*name` returned nothing for a nested `user.name` field.+ #[tokio::test]+ async fn field_caps_fields_filter_honors_leading_glob() {+ let router = crate::router::build_es_compat_router(test_state());+ let create = router+ .clone()+ .oneshot(+ Request::put("/leadglob-caps-e2e")+ .header("content-type", "application/json")+ .body(Body::from(+ json!({"mappings": {"properties": {"user": {"properties": {+ "name": {"type": "keyword"}, "age": {"type": "long"}+ }}}}})+ .to_string(),+ ))+ .expect("request"),+ )+ .await+ .expect("create");+ assert!(create.status().is_success());++ let caps = router+ .oneshot(+ Request::get("/leadglob-caps-e2e/_field_caps?fields=*name")+ .body(Body::empty())+ .expect("request"),+ )+ .await+ .expect("field_caps");+ assert!(caps.status().is_success());+ let bytes = to_bytes(caps.into_body(), usize::MAX).await.expect("bytes");+ let resp: Value = serde_json::from_slice(&bytes).expect("json");+ assert!(+ resp["fields"].get("user.name").is_some(),+ "fields=*name must match nested user.name (leading glob), got: {resp}"+ );+ // A field NOT matching the glob is absent.+ assert!(+ resp["fields"].get("user.age").is_none(),+ "user.age must not match *name: {resp}"+ );+ }+/// #209: dynamic mapping inferred every string as bare `text` — no/// `keyword` multi-field — so `GET _mapping` never advertised/// `<field>.keyword` and `_field_caps` (what Kibana uses for field@@ -34081,7 +34118,7 @@ pub async fn global_field_caps(if fields_filter != "*" {let matches = fields_filter.split(',')- .any(|f| source_field_matches(&name, f.trim()));+ .any(|f| glob_match(f.trim(), &name));if !matches {continue;}