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(query): name the {query, weight} shape on a bad hybrid clause (#1628)
xerj-orgd53ae1b8ae4f
diff --git a/engine/crates/xerj-query/src/parser.rs b/engine/crates/xerj-query/src/parser.rsindex 674a7f6c6..7af31259c 100644--- a/engine/crates/xerj-query/src/parser.rs+++ b/engine/crates/xerj-query/src/parser.rs@@ -3067,12 +3067,16 @@ fn parse_hybrid(params: &Value) -> Result<QueryNode> {.iter().enumerate().map(|(i, v)| {- let entry = v- .as_object()- .ok_or_else(|| qerr(format!("`hybrid.queries[{i}]` must be an object")))?;- let q_val = entry- .get("query")- .ok_or_else(|| qerr(format!("`hybrid.queries[{i}]` missing `query`")))?;+ let entry = v.as_object().ok_or_else(|| {+ qerr(format!(+ "`hybrid.queries[{i}]` must be an object {{\"query\": <clause>, \"weight\": <number>}}"+ ))+ })?;+ let q_val = entry.get("query").ok_or_else(|| {+ qerr(format!(+ "`hybrid.queries[{i}]` missing `query`; each item is {{\"query\": <clause>, \"weight\": <number>}} (weight defaults to 1)"+ ))+ })?;let query = parse_query(q_val)?;let weight = entry.get("weight").and_then(|v| v.as_f64()).unwrap_or(1.0) as f32;Ok(WeightedQuery { query, weight })@@ -6170,6 +6174,38 @@ mod tests {}}+ #[test]+ fn hybrid_item_missing_query_names_the_query_weight_shape() {+ let err = parse_query(&json!({+ "hybrid": {+ "queries": [+ {"weight": 1.0},+ {"query": {"match_all": {}}}+ ]+ }+ }))+ .unwrap_err();+ let msg = err.to_string();+ assert!(msg.contains("`hybrid.queries[0]` missing `query`"), "{msg}");+ assert!(+ msg.contains("{\"query\": <clause>, \"weight\": <number>}"),+ "{msg}"+ );+ assert!(msg.contains("weight defaults to 1"), "{msg}");++ let err = parse_query(&json!({+ "hybrid": { "queries": ["rotate keys"] }+ }))+ .unwrap_err();+ let msg = err.to_string();+ assert!(+ msg.contains(+ "`hybrid.queries[0]` must be an object {\"query\": <clause>, \"weight\": <number>}"+ ),+ "{msg}"+ );+ }+#[test]fn test_hybrid_learned_rejected() {// Learned fusion is not implemented — must fail loud rather thandiff --git a/landing/llms.txt b/landing/llms.txtindex 663783389..0d2ab331d 100644--- a/landing/llms.txt+++ b/landing/llms.txt@@ -78,7 +78,7 @@ No shell: once the corpus is indexed on the node, the MCP tool `xerj_code_search- **xerj_search** — lexical / structured search: `POST /{index}/_search` with a standard ES body, e.g. `{"query":{"match":{"title":"rust search"}}}`. Full DSL (`match`, `match_phrase`, `term`, `terms`, `range`, `bool`, `prefix`, `wildcard`, `exists`, `ids`, `fuzzy`, `query_string`) plus `aggs`, `sort`, `from`/`size`, `_source`, `highlight`. On large documents add `"fields":["_passage"]` and project `_source` (see Caveats).- **xerj_semantic_search** — over a `semantic_text` field, auto-embedded at ingest: `{"query":{"semantic":{"field":"body","query":"how do I rotate keys","k":10}}}`. **The name says semantic; the default embedder is lexical** — read the embedder caveat above before you promise a user "search by meaning".- **xerj_vector_search** — kNN over a `dense_vector` field: `{"query":{"knn":{"field":"embedding","query_vector":[…],"k":10,"num_candidates":100,"filter":{…}}}}`, or the top-level `{"knn":{…}}` form. Bring your own query vector. (HNSW-served unfiltered, exact scan when filtered — see Caveats.)-- **xerj_hybrid_search** — fuse lexical + vector/semantic: `{"query":{"hybrid":{"queries":[…],"fusion":"rrf"}}}` with a `weight` per clause. `fusion` is `"rrf"` (default, k=60) or `"linear"` — nothing else (see Caveats).+- **xerj_hybrid_search** — fuse lexical + vector/semantic. Each `queries` item is `{"query": <clause>, "weight": <number>}` (`weight` defaults to 1). Example: `{"query":{"hybrid":{"queries":[{"query":{"match":{"body":"rotate keys"}},"weight":1.0},{"query":{"semantic":{"field":"body","query":"how do I rotate keys","k":10}},"weight":1.0}],"fusion":"rrf"}}}`. `fusion` is `"rrf"` (default, k=60) or `"linear"` — nothing else (see Caveats).- **xerj_memory_store** — `POST /_memory/{namespace}` with `{"text":"user prefers dark mode","metadata":{…},"id":"opt","vector":[…]?,"dedup":true?,"dedup_threshold":0.95?}`. Text is auto-embedded; namespaces are isolated.- **xerj_memory_recall** — `POST /_memory/{namespace}/_recall` with `{"query":"what UI theme?","semantic":true,"k":5,"filter":{…}?,"recency_weight":0.2?}`. Modes in order: explicit `vector` kNN → `hybrid:true` (BM25 + server-side semantic over the same `query`, fused by reciprocal rank; `fusion:"linear"` opt-in) → `semantic:true` (server embeds) → plain `query` text (BM25). Same embedder caveat as `xerj_semantic_search`.