RECIPES

Recipes

Task-oriented AI & search recipes for building real things with XERJ — retrieval by meaning, agent memory, hybrid ranking, log analytics, and anomaly detection. Each recipe was verified end-to-end against a live XERJ before it was written, and ships with a runnable, dependency-free example.

01 Semantic search & RAG

Retrieval by meaning with semantic_text — auto-embed on ingest, no separate vector DB.

02 Give an AI agent long-term memory

A memory-backed agent on the /_memory API — store, semantic + keyword recall, metadata filters, forgetting, per-agent isolation.

03 Passage retrieval on long docs

semantic_text auto-embeds every overlapping passage; a long doc competes on any one of its sections via best-passage (max-sim) scoring — 98% top-3 vs 32% pooled.

04 Vector search (kNN)

Nearest-neighbor similarity search over dense_vector (HNSW), with filters.

05 Vector quantization

Opt a dense_vector field into scalar8 (int8_hnsw) — 4× smaller vectors, recall@10 ≈ 0.99.

06 Hybrid search

Keyword + vector in one query — results neither BM25 nor kNN finds alone.

07 Log analytics

From raw logs to dashboards — error rates, p95 latency, top services via aggregations.

08 Anomaly detection

Statistical _ml detectors that flag spikes in metrics/logs.

09 Continuous anomaly datafeeds

A live _ml datafeed that re-scores an index on a timer and stores new anomaly records you poll.

10 Migrate from Elasticsearch

Point your existing ES client at XERJ — same wire, change the URL.

11 Index a folder of PDFs, Word docs & web pages

One xerj-index pass walks a recursive folder of PDF/DOCX/HTML/MD/TXT, extracts + chunks + auto-embeds every file, then lexical, semantic & hybrid search return ranked, cited passages — measured 21/22 vs a fair grep baseline's 14/22, with the decisive win on binary_only (6/7 vs 0/7) because grep can't read a PDF/DOCX.