---
id: catalog-vector
name: Catalog Vector
version: 1.0.0
summary: Non-authoritative Qdrant vector search index owned by the Catalog bounded context for hybrid semantic and keyword book discovery.
owners:
  - catalog-experience-team
container_type: searchIndex
badges:
  - content: Search Index
    backgroundColor: purple
    textColor: purple
technology: qdrant
authoritative: false
access_mode: readWrite
classification: internal
retention: transient
residency: eastasia
purpose: Store searchable text and vector embeddings of active Catalog books for semantic and keyword-based discovery.
styles:
  icon: /icons/database/qdrant.svg
---

## Purpose & Ownership Boundary

Catalog Vector (`vectordb`) is the non-authoritative Qdrant search index owned by the Catalog bounded context for hybrid semantic and keyword book discovery. [[service|catalog-ingestion]] writes 1,536-dimensional embeddings asynchronously in batches, while [[service|catalog-api]] queries the index for candidate book IDs before hydrating authoritative prices, stock status, and ratings from [[container|catalog-database]].

## Data Store Profile

| Property                            | Value                                                                           |
| :---------------------------------- | :------------------------------------------------------------------------------ |
| **Bounded Context / Owner**         | Catalog — [[team\|catalog-experience-team]]                                     |
| **Engine / Technology**             | Qdrant (Qdrant Cloud in cloud; Qdrant container locally)                        |
| **Store Type**                      | Vector                                                                          |
| **Primary Writer(s)**               | [[service\|catalog-ingestion]]                                                  |
| **Primary Reader(s)**               | [[service\|catalog-api]]                                                        |
| **Authoritative / Source of Truth** | Derived Read Model (Ephemeral)                                                  |
| **Data Classification**             | Internal                                                                        |
| **Retention / TTL Policy**          | Transient (rebuildable derived projection from [[container\|catalog-database]]) |

## Logical Data Layout & Key Patterns

| Collection / Point Key                        | Stored Data                                                                                                                    | TTL / Eviction                                       | Invalidation / Update Trigger                                                                                                                                                                |
| :-------------------------------------------- | :----------------------------------------------------------------------------------------------------------------------------- | :--------------------------------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `data-bookworm-snippets` / `book_id` (`uuid`) | Assembled text (`Title`, `Description`, `Authors`, `Category`, `Publisher`) + `1,536`-dim cosine embedding (`Cohere.EmbedV40`) | Retained while book is active (`is_deleted = false`) | Asynchronous 5-minute batch triggered by [[service\|scheduler-service]] (`scheduler.process-vector-batch`) draining `pending_vector_updates`. Soft-deleted books are removed from the index. |

Commercial fields—prices, stock status, cover image URNs, and rating summaries—are intentionally excluded from Qdrant and always resolved from [[container|catalog-database]].

## Consistency, Isolation & Security Guardrails

- **Eventual search consistency:** Catalog mutations appear in semantic search after the next 5-minute [[service|scheduler-service]] tick and [[service|catalog-ingestion]] batch run (up to `200` books per batch).
- **Revision-safe single-writer batching:** [[service|catalog-ingestion]] acquires PostgreSQL advisory lock `740031001` and deletes queued items only when both `book_id` and `revision` match, preventing lost updates from concurrent edits. If embedding generation returns fewer vectors than active items, the batch fails without acknowledging the queue.
- **No direct external access:** Only [[service|catalog-ingestion]] writes to `data-bookworm-snippets` and only [[service|catalog-api]] queries it.

:::warning
**Derived Index Only — Never Authoritative:** `vectordb` is strictly a derived search projection. Never treat vector payloads as canonical product data, and never return prices or availability from Qdrant without hydrating from [[container|catalog-database]]. Because the index is fully rebuildable from `catalogdb`, collection resets carry zero data-loss risk.
:::

## Operational & Resilience Notes

<AccordionGroup>
	<Accordion title="Hosting, environment parity, and lag triage">
		- **Local vs. Cloud:** Local development runs a persistent Qdrant container managed by Aspire;
		cloud environments connect to an external Qdrant Cloud cluster via environment connection
		strings. - **Triaging stale search results:** Inspect three signals together: pending row count
		and oldest `updated_at` in `catalogdb.pending_vector_updates`, scheduled job history in
		[[container|scheduler-database]], and Qdrant/Microsoft Foundry traces in OpenTelemetry.
	</Accordion>
</AccordionGroup>

## Architecture Visualizations

<NodeGraph />

<MermaidFileLoader file="mermaids/catalog-vector-diagram-1.mmd" />

## Related Documentation

- [[service|catalog-ingestion]] — Worker generating embeddings and updating Qdrant points.
- [[service|catalog-api]] — Hybrid search query pipeline and PostgreSQL hydration.
- [[container|catalog-database]] — Relational source of truth and `pending_vector_updates` queue.
- [[container|scheduler-database]] — Schedule store driving the 5-minute vector batch trigger.
- [[adr|adr-002-hybrid-vector-search-qdrant]] — Decision adopting Qdrant for hybrid catalog search.
- [[adr|adr-003-database-queue-for-vector-indexing]] — Decision for coalesced database-queue indexing.
- [[doc|operational/005-backup-restore-and-dr]] — Platform backup, restore, and disaster recovery runbook.
