MCPcopy Index your code
hub / github.com/ChuckHend/pg_vectorize

github.com/ChuckHend/pg_vectorize @v0.26.2

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.26.2 ↗ · + Follow
498 symbols 1,013 edges 74 files 45 documented · 9%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

pg_vectorize: a VectorDB on Postgres

PostgreSQL

A Postgres server and extension that automates the transformation and orchestration of text to embeddings and provides hooks into the most popular LLMs. This allows you to do get up and running and automate maintenance for vector search, full text search, and hybrid search, which enables you to quickly build RAG and search engines on Postgres.

This project relies heavily on the work by pgvector for vector similarity search, pgmq for orchestration in background workers, and SentenceTransformers.


API Documentation: https://chuckhend.github.io/pg_vectorize/

Source: https://github.com/tembo-io/pg_vectorize

Overview

pg_vectorize provides two ways to add semantic, full text, and hybrid search to any Postgres making it easy to build retrieval-augmented generation (RAG) on Postgres. This project provides an external server only implementation and SQL experience via a Postgres extension.

Modes at a glance:

  • HTTP server (recommended for managed DBs): run a standalone service that connects to Postgres and exposes a REST API (POST /api/v1/table, GET /api/v1/search).
  • Postgres extension (SQL): install the extension into Postgres and use SQL functions like vectorize.table() and vectorize.search() (requires filesystem access to Postgres; see ./extension/README.md).

Quick start — HTTP server

Run Postgres and the HTTP servers locally using docker compose:

# runs Postgres, the embeddings server, and the management API
docker compose up -d

Load the example dataset into Postgres (optional):

psql postgres://postgres:postgres@localhost:5432/postgres -f server/sql/example.sql
CREATE TABLE
INSERT 0 40

Create an embedding job via the HTTP API. This generates embeddings for the existing data and continuously watches for updates or new data:

curl -X POST http://localhost:8080/api/v1/table -d '{
        "job_name": "my_job",
        "src_table": "my_products",
        "src_schema": "public",
        "src_columns": ["product_name", "description"],
        "primary_key": "product_id",
        "update_time_col": "updated_at",
        "model": "sentence-transformers/all-MiniLM-L6-v2"
    }' -H "Content-Type: application/json"
{"id":"16b80184-2e8e-4ee6-b7e2-1a068ff4b314"}

Search using the HTTP API:

curl -G \
  "http://localhost:8080/api/v1/search" \
  --data-urlencode "job_name=my_job" \
  --data-urlencode "query=camping backpack" \
  --data-urlencode "limit=1" \
  | jq .
[
  {
    "description": "Storage solution for carrying personal items on ones back",
    "fts_rank": 1,
    "price": 45.0,
    "product_category": "accessories",
    "product_id": 6,
    "product_name": "Backpack",
    "rrf_score": 0.03278688524590164,
    "semantic_rank": 1,
    "similarity_score": 0.6296013593673706,
    "updated_at": "2025-10-05T00:14:39.220893+00:00"
  }
]

Which should I pick?

  • Use the HTTP server when your Postgres is managed (RDS, Cloud SQL, etc.) or you cannot install extensions. It requires only that pgvector is available in the database. You the HTTP services separately.
  • Use Postgres extension when you self-host Postgres and can install extensions. This provides an in-database experience and direct SQL APIs for vectorization and RAG.

If you want hands-on SQL examples or to install the extension into Postgres, see ./extension/README.md. For full HTTP API docs and deployment notes, see ./server/README.md.

For contribution guidelines see CONTRIBUTING.md in the repo root.

Extension points exported contracts — how you extend this code

EmbeddingProvider (Interface)
(no doc) [6 implementers]
core/src/transformers/providers/mod.rs

Core symbols most depended-on inside this repo

get_guc
called by 15
extension/src/guc.rs
from_env_default
called by 11
core/src/config.rs
get_guc
called by 11
core/src/guc.rs
api_name
called by 8
core/src/types.rs
create_event_trigger
called by 8
core/src/query.rs
get_provider
called by 8
core/src/transformers/providers/mod.rs
parse_embed_calls
called by 8
proxy/src/embeddings.rs
check_input
called by 7
core/src/query.rs

Shape

Function 347
Class 69
Method 59
Enum 18
Route 4
Interface 1

Languages

Rust94%
Python6%

Modules by API surface

core/src/query.rs99 symbols
core/src/types.rs30 symbols
extension/tests/integration_tests.rs22 symbols
core/src/transformers/providers/openai.rs15 symbols
worker/src/health.rs13 symbols
server/src/routes/search.rs13 symbols
proxy/src/embeddings.rs13 symbols
extension/src/api.rs12 symbols
server/tests/tests.rs11 symbols
extension/tests/util.rs11 symbols
extension/src/util.rs11 symbols
proxy/src/message_parser.rs10 symbols

Datastores touched

postgresDatabase · 1 repos

For agents

$ claude mcp add pg_vectorize \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact