Deploy PostgreSQL with pgvectorscale and pg_textsearch

PostgreSQL 18 with pgvectorscale and pg_textsearch extensions.

Deploy PostgreSQL with pgvectorscale and pg_textsearch

/var/lib/postgresql/data

Deploy and Host PostgreSQL with pgvectorscale and pg_textsearch on Railway

PostgreSQL 18 with pgvectorscale and pg_textsearch enables hybrid search combining vector similarity and BM25 text ranking in a single database. pgvectorscale provides high-performance embedding search using StreamingDiskANN indexes, while pg_textsearch adds modern ranked text search with the BM25 algorithm.

About Hosting PostgreSQL with pgvectorscale and pg_textsearch

This template deploys a PostgreSQL 18 database with three extensions pre-installed: pgvector for vector data types, pgvectorscale for optimized vector indexing, and pg_textsearch for BM25 text search. The extensions are automatically enabled on database creation, so you can immediately start building AI-powered search applications. No additional configuration is required - just connect and start creating indexes on your embedding and text columns.

Common Use Cases

  • RAG applications: Combine semantic vector search with keyword matching for retrieval-augmented generation
  • Hybrid search: Use vector similarity for meaning and BM25 for exact term matching in a single query
  • Document search: Index large document collections with both embeddings and full-text search
  • E-commerce search: Match products using natural language queries with vector embeddings and text relevance
  • Knowledge bases: Build searchable knowledge systems that understand both concepts and keywords

Dependencies for PostgreSQL with pgvectorscale and pg_textsearch Hosting

  • PostgreSQL 18
  • pgvector v0.8.1
  • pgvectorscale v0.9.0
  • pg_textsearch v0.1.1-dev

Deployment Dependencies

  • pgvector - Vector similarity search for PostgreSQL
  • pgvectorscale - StreamingDiskANN indexing for high-performance vector search
  • pg_textsearch - BM25 ranked text search for PostgreSQL

Implementation Details

Create vector and BM25 indexes on your tables:

-- Vector similarity search
CREATE TABLE documents (
    id BIGSERIAL PRIMARY KEY,
    content TEXT,
    embedding VECTOR(1536)
);
CREATE INDEX ON documents USING diskann (embedding vector_cosine_ops);

-- BM25 text search
CREATE INDEX ON documents USING bm25(content) WITH (text_config='english');

-- Query with hybrid search
SELECT content,
       embedding <=> $1 AS vector_score,
       content <@> $2 AS text_score
FROM documents
ORDER BY 0.7 * (embedding <=> $1) + 0.3 * (content <@> $2)
LIMIT 10;

Why Deploy PostgreSQL with pgvectorscale and pg_textsearch on Railway?

Railway is a singular platform to deploy your infrastructure stack. Railway will host your infrastructure so you don't have to deal with configuration, while allowing you to vertically and horizontally scale it.

By deploying PostgreSQL with pgvectorscale and pg_textsearch on Railway, you are one step closer to supporting a complete full-stack application with minimal burden. Host your servers, databases, AI agents, and more on Railway.


Template Content

More templates in this category

View Template
Postgres-to-R2 Backup
Auto back up PostgreSQL databases to Cloudflare R2 with optional encryption

View Template
ReadySet
A lightweight caching engine for Postgres

View Template
Simple S3
Deploy a S3-compatible storage service with a pre-named bucket.