Skip to main content
Ingest unstructured documents into PostgreSQL with the pgvector extension for retrieval-augmented generation (RAG) and semantic search. The pipeline extracts text from the document, chunks it using a configurable strategy, generates vector embeddings, and upserts the chunks with metadata into a PostgreSQL table with a vector column. pgvector uses your existing PostgreSQL infrastructure — no separate vector database server required. Standard SQL can be used to combine vector similarity search with traditional filters.

Configuration

Supported File Types

For structured data (CSV, JSON, XML), use the standard PostgreSQL database destination instead.

Vault Secrets

PostgreSQL connection (for pgvector)

This is separate from the pipeline’s standard oss/postgres secret so the vector store can target a different database or server.

Embedding API

The embedding secret is server-level (ai.embedding.secretName, default oss/embedding) and is seeded automatically by docker/vault-init.sh. See AI Configuration and the Qdrant docs for the full picture.
For Anthropic-only deployments, the bundled TEI sidecar serves bge-m3 and vault-init.sh seeds the embedding secret to point at it — no OpenAI key required.

Chunking Strategies

Documents are split into chunks before embedding. Each chunk becomes a row in the PostgreSQL table with the document’s metadata columns plus chunk_index, filename, and source_pipeline.
  • chunkSize (default 500): maximum characters per chunk
  • chunkOverlap (default 50): characters of overlap between consecutive chunks

Metadata

Static metadata is stored as dedicated columns in the PostgreSQL table:
Use snake_case for metadata keys since they become PostgreSQL column names. This enables powerful combined queries:
Every row automatically includes:
  • id — deterministic UUID (idempotent upserts)
  • text — the chunk text
  • chunk_index — position of the chunk in the document
  • filename — original uploaded filename
  • source_pipeline — pipeline name
  • embedding — vector column for similarity search

How It Works

  1. Upload — an unstructured file is uploaded via POST /api/v1/pipeline/upload
  2. Extract — text is extracted from the document
  3. Chunk — text is split into chunks using the configured strategy
  4. Embed — each chunk is sent to the embedding API to generate a vector
  5. Upsert — chunks are upserted into PostgreSQL with INSERT ... ON CONFLICT DO UPDATE
  6. Notify — a pipeline notification is published on completion
The pgvector extension and table are auto-created on first upsert. Vector dimension is detected from the embedding model.

Running PostgreSQL with pgvector

The standard PostgreSQL Docker image does not include pgvector. Use the pgvector image:
Port 5433 avoids conflict with the pipeline’s PostgreSQL instance on 5432. To add pgvector to an existing PostgreSQL instance:

Verifying

Advantages Over Dedicated Vector Databases

  • No separate server — uses your existing PostgreSQL infrastructure
  • Standard SQL — combine vector search with traditional WHERE clauses, JOINs, aggregations
  • ACID transactions — full transactional guarantees on vector data
  • Familiar tooling — use psql, pgAdmin, any PostgreSQL client
  • No new dependencies — uses the existing PostgreSQL JDBC driver