ADR-002: Use Qdrant hybrid vector and keyword search for product discovery
Text search finds candidate book IDs in Qdrant using embeddings plus keyword matching, then loads canonical records from PostgreSQL.
1. Context & Problem
Customers look for BookEntityv1.0.0BookCanonical sellable title in the product catalog, encapsulating descriptive metadata, pricing, stock availability, taxono...Ownercatalog-experience-teamOpen docss in two distinct ways: by meaning or theme (concepts described in a synopsis) and by exact words (titles or AuthorEntityv1.0.0AuthorRepresents a credited author of one or more books in the product catalog, enforcing display-name validity and referentia...Ownercatalog-experience-teamOpen docs names). Traditional database text matching alone struggles to understand semantic intent when shoppers do not use the exact words stored in a book’s description.
At the same time, search results must reflect current, authoritative values for filters, sorting, pricing, and availability. Storing a complete copy of every book inside a search engine would turn the search index into a second, potentially stale catalog.
2. Business Value
- Higher discovery relevance: Shoppers find relevant books whether they search by broad concept, topic, or exact title and author names.
- Always-accurate product details: Prices, availability, sorting, and structured filters always reflect the live authoritative catalog rather than a stale search copy.
- Clean separation of concerns: Search relevance tuning and indexing remain independent of the core product data contract, keeping stale search text clearly separated from current product truth.
3. How It Works
Catalog separates finding candidate matches from delivering authoritative product data:
- Maintain a focused search index: Catalog VectorContainerv1.0.0Catalog VectorNon-authoritative Qdrant vector search index owned by the Catalog bounded context for hybrid semantic and keyword book d...Ownercatalog-experience-teamDiagramOpen docs holds one search entry for each active BookEntityv1.0.0BookCanonical sellable title in the product catalog, encapsulating descriptive metadata, pricing, stock availability, taxono...Ownercatalog-experience-teamOpen docs. Each entry contains searchable text built from the book’s title, description, AuthorEntityv1.0.0AuthorRepresents a credited author of one or more books in the product catalog, enforcing display-name validity and referentia...Ownercatalog-experience-teamOpen docss, CategoryEntityv1.0.0CategorySingle-level taxonomy classification grouping books by subject or genre within the product catalog.Ownercatalog-experience-teamOpen docs, and PublisherEntityv1.0.0PublisherRepresents a publishing house or imprint associated with books in the product catalog.Ownercatalog-experience-teamOpen docs, paired with a semantic meaning representation. Prices, cover images, and rating summaries are intentionally left out, and retired books are removed.
- Match by meaning and keywords together: When a customer runs a text search, Catalog APIServicev1.0.0Catalog APIInternal HTTP and gRPC service for Catalog product management, hybrid discovery, and authoritative book metadata. PublishesBookUpdatedRatingFailedIntegrationEventSubscribesCreatePublisher, UpdatePublisher +24APIsOpenAPI, AsyncAPIOwnercatalog-experience-teamDiagramRepositoryOpen docs converts the search query into a semantic representation and performs a hybrid search in Catalog VectorContainerv1.0.0Catalog VectorNon-authoritative Qdrant vector search index owned by the Catalog bounded context for hybrid semantic and keyword book d...Ownercatalog-experience-teamDiagramOpen docs that combines conceptual similarity with exact keyword matching.
- Return candidate identifiers, not final records: The search engine returns only a list of matching book identifiers—it never serves as the final product response.
- Hydrate and filter from the authoritative database: Catalog APIServicev1.0.0Catalog APIInternal HTTP and gRPC service for Catalog product management, hybrid discovery, and authoritative book metadata. PublishesBookUpdatedRatingFailedIntegrationEventSubscribesCreatePublisher, UpdatePublisher +24APIsOpenAPI, AsyncAPIOwnercatalog-experience-teamDiagramRepositoryOpen docs fetches the live book records for those candidates from Catalog DatabaseContainerv1.0.0Catalog DatabaseAuthoritative PostgreSQL system of record owned by the Catalog bounded context for books, authors, categories, publisher...Ownercatalog-experience-teamDiagramOpen docs, applying the customer’s requested filters, sort order, and page bounds before returning the response.
Browsing and filtered listing requests that do not include a search term bypass the search index entirely and query Catalog DatabaseContainerv1.0.0Catalog DatabaseAuthoritative PostgreSQL system of record owned by the Catalog bounded context for books, authors, categories, publisher...Ownercatalog-experience-teamDiagramOpen docs directly.
4. Trade-offs & Lessons Learned
Alternatives considered
- Database-only text search: Simpler to operate and immediately consistent with edits, but performs poorly on semantic intent when queries do not match exact phrasing in descriptions.
- Semantic vector-only search: Strong at conceptual matching, but weaker on exact title and author lookups. Hybrid search combines semantic recall with exact-term precision.
- Store the full book record in the search engine: Eliminates the second database lookup, but duplicates canonical state and makes stale prices or partial updates difficult to isolate from authoritative data.
Trade-offs & operational considerations
- Asynchronous index freshness: Because Catalog VectorContainerv1.0.0Catalog VectorNon-authoritative Qdrant vector search index owned by the Catalog bounded context for hybrid semantic and keyword book d...Ownercatalog-experience-teamDiagramOpen docs is updated in the background (see ADR-003: Maintain the vector index asynchronously through a database-backed queueDecision Recordv1.0.0ADR-003: Maintain the vector index asynchronously through a database-backed queueDatabase triggers enqueue changed books, and Catalog Ingestion drains the queue in batches to update Qdrant, decoupling ...Ownercatalog-experience-teamOpen docs), newly added or edited books can take time to appear in text-search results, even though browsing lists reflect changes immediately.
- Additional runtime dependencies for text search: Text search relies on query embedding generation and search-store availability; non-search browsing remains purely database-backed (see ADR-001: Use PostgreSQL as the Catalog system of recordDecision Recordv1.0.0ADR-001: Use PostgreSQL as the Catalog system of recordCatalog Database (PostgreSQL) is the single authoritative store for books, authors, categories, and publishers; cache an...Ownercatalog-experience-teamOpen docs).
- Reindexing cost on model or field changes: Adding new searchable fields or upgrading the underlying embedding model requires coordinated updates and a full catalog rebuild, which consumes extra ingestion and embedding capacity.
5. Technical Reference
- Search container: Catalog VectorContainerv1.0.0Catalog VectorNon-authoritative Qdrant vector search index owned by the Catalog bounded context for hybrid semantic and keyword book d...Ownercatalog-experience-teamDiagramOpen docs (Qdrant), holding one record per active BookEntityv1.0.0BookCanonical sellable title in the product catalog, encapsulating descriptive metadata, pricing, stock availability, taxono...Ownercatalog-experience-teamOpen docs keyed by book UUID.
- Indexed payload & vector contract:
- Searchable text built from:
title,description,authors,category, andpublisher. - Excluded from index: prices, images, rating summaries, and inactive/soft-deleted books.
- Vector format:
1,536-dimensionembedding using cosine similarity (part of the index contract; changing the embedding model requires rebuilding the index so stored book vectors and query vectors stay compatible).
- Searchable text built from:
- Query execution path (Catalog APIServicev1.0.0Catalog APIInternal HTTP and gRPC service for Catalog product management, hybrid
discovery, and authoritative book metadata.
PublishesBookUpdatedRatingFailedIntegrationEventSubscribesCreatePublisher, UpdatePublisher +24APIsOpenAPI, AsyncAPIOwnercatalog-experience-teamDiagramRepositoryOpen docs):
- Generate a query embedding for the search term.
- Run hybrid vector + keyword search in Qdrant to retrieve candidate book UUIDs.
- Query Catalog DatabaseContainerv1.0.0Catalog DatabaseAuthoritative PostgreSQL system of record owned by the Catalog bounded context for books, authors, categories, publisher...Ownercatalog-experience-teamDiagramOpen docs (PostgreSQL) for the candidate IDs, applying SQL filters, sorting, and paging against canonical records.
- Non-search paths: Browse and filtered-list requests without a text-search term remain PostgreSQL-backed only.
- Indexing pipeline & source of truth: Maintained asynchronously via ADR-003: Maintain the vector index asynchronously through a database-backed queueDecision Recordv1.0.0ADR-003: Maintain the vector index asynchronously through a database-backed queueDatabase triggers enqueue changed books, and Catalog Ingestion drains the queue in batches to update Qdrant, decoupling ...Ownercatalog-experience-teamOpen docs, with canonical authority governed by ADR-001: Use PostgreSQL as the Catalog system of recordDecision Recordv1.0.0ADR-001: Use PostgreSQL as the Catalog system of recordCatalog Database (PostgreSQL) is the single authoritative store for books, authors, categories, and publishers; cache an...Ownercatalog-experience-teamOpen docs. Changing searchable fields requires coordinated updates to text construction, database queue triggers, and reindexing.