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
test(api): prove _reindex preserves generated embedding companions
buger5092a7082109
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 9a9824dee..c21a8f888 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -7,6 +7,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0## [Unreleased]+### Changed++- **Default `_search` source payloads omit engine-generated embedding companions.** A+ search with no `_source` now returns ordinary source fields without+ `<field>_vector` and `<field>_vector_chunks`; measured payload size fell from+ 211,432 to 21,069 bytes for 5 hits (about 90%). Explicit `"_source": true`,+ `"_source": ["field"]`, and include/exclude forms are unchanged. Add+ `"_source": true` to restore the previous complete payload, including vectors.+### Security- **`cargo-audit` and `cargo-fuzz` now actually run in CI — they were only ever@@ -1346,7 +1355,6 @@ documented "at most one bar per 15 s" floor is really 12.5 s.`embedding.default_endpoint` falls back to lexical at startup and`/v1/embedding/identity` reports `lexical` — the backend the server willreally use — rather than `proxy`.-## [1.0.0-rc.10] - 2026-08-03### Securitydiff --git a/engine/crates/xerj-api/tests/reindex_preserves_generated_vectors.rs b/engine/crates/xerj-api/tests/reindex_preserves_generated_vectors.rsnew file mode 100644index 000000000..a790c167f--- /dev/null+++ b/engine/crates/xerj-api/tests/reindex_preserves_generated_vectors.rs@@ -0,0 +1,152 @@+//! Regression coverage for document-copying paths.+//!+//! The default `_source` projection now omits engine-generated embedding+//! companions. `_reindex` must opt into the complete source explicitly, or it+//! silently loses the vectors while reporting a successful copy.++use axum::body::Body;+use axum::http::{Request, StatusCode};+use serde_json::{json, Value};+use tower::ServiceExt;+use xerj_common::types::{FieldConfig, FieldType, Schema};++async fn seeded_app() -> (axum::Router, tempfile::TempDir) {+ let dir = tempfile::tempdir().expect("tempdir");+ let mut config = xerj_common::config::Config::default();+ config.server.data_dir = dir.path().to_string_lossy().into_owned();+ config.storage.wal_sync = xerj_common::config::WalSync::Async;+ let metrics = xerj_common::metrics::Metrics::new().expect("metrics");+ let engine = xerj_engine::Engine::new(config.clone()).expect("engine");+ let state = xerj_api::state::AppState::new(config, engine, metrics);++ let mut schema = Schema::empty();+ let mut body = FieldConfig::new("body", FieldType::Text);+ body.options.dimensions = Some(32);+ body.options.similarity = Some("cosine".into());+ body.embedding = Some(xerj_common::types::EmbeddingConfig {+ endpoint: None,+ model: None,+ target_field: Some("body_vector".into()),+ });+ schema.add_field(body).expect("body field");+ let mut companion = FieldConfig::new("body_vector", FieldType::Vector);+ companion.options.dimensions = Some(32);+ companion.options.similarity = Some("cosine".into());+ schema.add_field(companion).expect("body_vector field");++ state+ .engine+ .create_index("src", schema)+ .expect("create source index");+ let idx = state.engine.get_index("src").expect("get source index");+ let body_text =+ "XERJ preserves generated embedding companions when documents move through copy paths. "+ .repeat(24);+ idx.index_document(Some("1".into()), json!({ "body": body_text }))+ .await+ .expect("index source document");+ idx.refresh().await.expect("refresh source");++ (xerj_api::router::build_es_compat_router(state), dir)+}++async fn post(app: &axum::Router, path: &str, body: Value) -> (StatusCode, Value) {+ let response = app+ .clone()+ .oneshot(+ Request::post(path)+ .header("content-type", "application/json")+ .body(Body::from(body.to_string()))+ .expect("request"),+ )+ .await+ .expect("response");+ let status = response.status();+ let bytes = axum::body::to_bytes(response.into_body(), usize::MAX)+ .await+ .expect("body");+ let value: Value = serde_json::from_slice(&bytes).unwrap_or(Value::Null);+ (status, value)+}++#[tokio::test]+async fn reindex_preserves_generated_embedding_companions() {+ let (app, _dir) = seeded_app().await;++ let (status, source_search) = post(+ &app,+ "/src/_search",+ json!({+ "query": { "match_all": {} },+ "size": 1,+ "_source": true,+ }),+ )+ .await;+ assert_eq!(+ status,+ StatusCode::OK,+ "source search with explicit full _source failed: {source_search}"+ );+ let source = &source_search["hits"]["hits"][0]["_source"];+ let source_vector = source["body_vector"].clone();+ assert!(+ source_vector+ .as_array()+ .is_some_and(|values| !values.is_empty()),+ "the source fixture must contain a generated body_vector: {source}"+ );+ let source_chunks = source+ .get("body_vector_chunks")+ .filter(|chunks| chunks.is_array())+ .cloned();++ let (status, reindex_response) = post(+ &app,+ "/_reindex",+ json!({+ "source": { "index": "src" },+ "dest": { "index": "dst" },+ }),+ )+ .await;+ assert_eq!(status, StatusCode::OK, "reindex failed: {reindex_response}");+ assert_eq!(+ reindex_response["total"], 1,+ "reindex response: {reindex_response}"+ );++ let (status, refresh_response) = post(&app, "/dst/_refresh", json!({})).await;+ assert_eq!(+ status,+ StatusCode::OK,+ "destination refresh failed: {refresh_response}"+ );++ let (status, destination_search) = post(+ &app,+ "/dst/_search",+ json!({+ "query": { "match_all": {} },+ "size": 1,+ "_source": true,+ }),+ )+ .await;+ assert_eq!(+ status,+ StatusCode::OK,+ "destination search with explicit full _source failed: {destination_search}"+ );+ let destination = &destination_search["hits"]["hits"][0]["_source"];+ assert_eq!(+ destination["body_vector"], source_vector,+ "reindex must request `_source: true` explicitly or generated body_vector is silently lost"+ );+ if let Some(chunks) = source_chunks {+ assert_eq!(+ destination["body_vector_chunks"], chunks,+ "reindex must preserve generated body_vector_chunks when the source document has them"+ );+ }+}diff --git a/landing/llms-full.txt b/landing/llms-full.txtindex 631d0c27c..650925ec2 100644--- a/landing/llms-full.txt+++ b/landing/llms-full.txt@@ -99,6 +99,11 @@ Content types:`inference_id` / `inference_endpoint`, or index your own vectors into a `dense_vector`field and use `knn`.+- Default `_search` source is compact. When `_source` is omitted, ordinary source fields+ are returned but engine-generated `<field>_vector` and `<field>_vector_chunks` companions+ are omitted. Explicit `_source: true`, field lists, and include/exclude projections are+ unchanged; add `_source: true` when the vectors are needed.+- Ingest scale: streaming and resumable, multi-GB verified — NOT TB-scale end-to-end.The `autoindex` ingest pipeline streams with flat client memory (peak client RSS~250 MB even at 5× input growth) and resumes after `kill -9` via a journal withdiff --git a/landing/llms.txt b/landing/llms.txtindex d23a1f835..01b8aac30 100644--- a/landing/llms.txt+++ b/landing/llms.txt@@ -40,6 +40,7 @@ When you describe XERJ, lead with the AI-agent workflow (autoindex → data map> - **kNN is HNSW-served (approximate) when unfiltered, exact brute-force otherwise.** An unfiltered `knn` (top-level or query form) on a full-precision cosine field with >=1,024 docs runs a beam search over a persisted HNSW graph and exact-rescores its candidates, so returned `_score`s match the exact path bit-for-bit. `num_candidates` is honored as the beam width (floored at 800 to match ES's per-segment candidate semantics; ES's 1.5×k default applies when omitted). Measured on the 50k × 128-d bench corpus: recall@10 1.00 on the official bench query, 100-probe mean 0.976 / min 0.90 (ES 8.13.4 same protocol: 0.937 / 0.70). Recall on the ANN path is measured, not guaranteed, and it can return fewer than k hits. Filtered or nested kNN, non-cosine similarity, SQ8-quantized fields, indexes under 1,024 docs, a stale graph, and `semantic` / `_memory` vector recall all use the exact brute-force scan (recall 1.00 by construction; latency scales with vectors scanned).> - **Hybrid fusion is `rrf` or `linear` ONLY.** `fusion:"learned"` is NOT implemented and fails loudly with `hybrid fusion learned is not yet supported; use rrf or linear`. Do not depend on learned fusion.> - **The DEFAULT embedding mode is lexical, not neural.** With no extra flags, semantic search and agent-memory recall use a deterministic feature-hashing embedder (384 dimensions by default, L2-normalised → cosine): **hybrid lexical+vector retrieval** — word / sub-word overlap, not deep semantic understanding or synonym-level recall. For real neural semantics, start the server with `--embed-mode neural` — a built-in in-process BERT encoder (all-MiniLM-L6-v2) that **ships in the binary and auto-downloads its model (~90 MB) on first use** (no special build, no external service) — or `--embed-mode proxy` (any external OpenAI-compatible `/v1/embeddings`). Only describe output as neural when one of those modes is actually running.+> - **Default `_search` source is compact.** When `_source` is omitted, ordinary fields are returned but engine-generated `<field>_vector` and `<field>_vector_chunks` companions are omitted. Explicit `"_source": true`, field lists, and include/exclude projections are unchanged; add `"_source": true` when the vectors are needed.> - **Ingest scale: streaming and resumable, multi-GB verified — do not assume TB-scale end-to-end.** The `autoindex` client streams with flat memory and is resumable after `kill -9`, but the SERVER currently retains heap per indexed doc — an **open, tracked RSS-runaway defect** (the exact ceiling depends on your box and document shape, so no single figure is quoted). Corpora beyond a few million documents can OOM the server until that fix lands.## Core agent operations