# Embedding and retrieval :::{figure} /diagrams/flow-retrieval.svg :alt: Embedding and retrieval :width: 100% ::: A corpus, an embedding job and a search. The API queues work; a worker prepares, encodes, stores and indexes it; searches read the serving index. ## Building a corpus | Step | What happens | Route or tool | |---|---|---| | 1 | Create a corpus from catalog sources | `POST /v1/retrieval/corpora`, `retrieval_create_corpus` | | 2 | The job registry (PostgreSQL) records the corpus and its sources | | | 3 | Submit an embedding job for one source and one embedding space | `POST /v1/retrieval/corpora/{corpus_id}/jobs`, `retrieval_submit` | | 4 | The job is queued with an idempotency key and a reference to the caller's model grant | | | 5-6 | `retrieval-worker` claims a runnable job with a lease and prepares model inputs within the byte budget | | | 7-8 | The encoder (a model pack adapter) encodes the inputs after GPU admission, one vector per input | | | 9-11 | Vector artifacts are written and recorded, an index generation is built, and the generation is published atomically | | | 12 | Poll the job. Stages: queued, resolved, prepared, embedded, persisted, searchable, completed | `GET .../jobs/{job_id}` | ## Searching `POST /v1/retrieval/search` (MCP `retrieval_search`) takes text, content, a vector or a stored artifact. A text or content query is encoded in the same space, the serving index is searched with filters and an optional snapshot, and ranked hits come back with provenance. ## State | State | Where | |---|---| | Jobs, corpora, artifact registry | `geonemo_retrieval` schema | | Vector artifacts | Vector files on disk | | Serving index | Milvus, provisioned by the operator, optional | Sources enter through a sensor-neutral port; packs register input types and product resolvers. Vectors computed elsewhere can be imported with `POST /v1/retrieval/corpora/{corpus_id}/imports`. Reference: {doc}`/_generated/reference/rest/retrieval`.