A practical walkthrough of building a RAG system using Apache Camel, PostgreSQL, and pgvector, deliberately kept simple and debuggable. The pipeline covers three steps: indexing documents by chunking and storing embeddings, retrieving relevant chunks via nearest-neighbor SQL queries using pgvector's distance operator, and generating answers grounded in retrieved context. The approach treats semantic similarity as a standard SQL query, making failure modes visible and isolated. The post also covers extending the pattern beyond Q&A to semantic product search and ticket deduplication, and honestly addresses limitations like chunking quality, threshold tuning, and cost at scale.

Table of contents
A quick glossaryThe anatomy of a RAG pipelineStep 1: Index (chunk → embed → store)Step 2: Retrieve (similarity as SQL)Step 3: Answer (or refuse)Beyond document Q&A: Reusing the patternLimitationsTakeawayNext stepsSort: