Part 4: Building Vector Search with TypeScript

← Part 3: pgvector Setup | Part 5: Advanced Queries β†’

The Knowledge Base That Nobody Used

I built a customer support knowledge base. It had everything:

  • 500+ carefully written articles

  • Perfect categorization

  • Beautiful UI

  • Traditional search

Usage: 12% of tickets. Support agents ignored it and asked engineers directly.

Why? The search was useless:

  • Query: "customer can't login" β†’ 0 results

  • (Article title: "Authentication Troubleshooting Guide")

  • Query: "payment failed" β†’ Wrong articles

  • (Returns billing setup, not payment errors)

I rebuilt it with semantic search. Same knowledge base, vector-powered search.

Usage: 12% β†’ 78%. Support ticket resolution time: 4.2 hours β†’ 1.3 hours. Engineers finally got time to code instead of answering the same questions.

This article shows you exactly how I built it with TypeScript and pgvector.

Project Setup

Initialize TypeScript Project

TypeScript Configuration

Environment Variables

Package Scripts

Prisma Schema Setup

Embedding Service

Vector Search Service

Data Ingestion Service

REST API Endpoints

Testing the API

Search Articles

Add Article

Find Similar Articles

What's Next

In this article, you learned:

  • βœ… Complete TypeScript project setup with Prisma and pgvector

  • βœ… Embedding service with batching and retry logic

  • βœ… Vector search service with filtering

  • βœ… Hybrid search combining vectors and keywords

  • βœ… Data ingestion with bulk import

  • βœ… Production-ready REST API

Next: Advanced queries, filtering strategies, and performance optimization techniques.


← Part 3: pgvector Setup | Part 5: Advanced Queries β†’

Last updated