---
title: "Building AI Search on Heroku"
description: "A reference RAG architecture on Heroku pairs pgvector cosine-similarity search (top 20 chunks) with a cross-encoder reranker (Cohere Rerank 3.5, top 5), so answers come from documents that actually address the query rather than ones that are merely semantically close."
url: "https://swe.quest/articles/building-ai-search-on-heroku-fdce052b7ed2fc31"
canonical: "https://www.heroku.com/blog/building-ai-search-on-heroku/"
source: "Heroku Engineering"
published: "2026-01-29"
difficulty: "medium"
kind: "How-to"
reading_minutes: 3
tags: ["rag","vector-search","postgres","search","llms"]
---

# Building AI Search on Heroku

A post on [Heroku Engineering](https://swe.quest/sources/heroku.md), published 2026-01-29, 3 min read, How-to. Original: [https://www.heroku.com/blog/building-ai-search-on-heroku/](https://www.heroku.com/blog/building-ai-search-on-heroku/)

## Summary

A reference RAG architecture on Heroku pairs pgvector cosine-similarity search (top 20 chunks) with a cross-encoder reranker (Cohere Rerank 3.5, top 5), so answers come from documents that actually address the query rather than ones that are merely semantically close. Indexing crawls sites using a junk-content heuristic, splits text into 1000-character chunks with 200-character overlap at paragraph or sentence boundaries, and batch-inserts embeddings with Postgres unnest. Generation uses Claude 3.5 Sonnet, and Server-Sent Events stream pipeline progress and sources to the client. Reranking can be switched off when latency matters more than precision.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [RAG & retrieval](https://swe.quest/tags/rag.md) (AI & ML)
- [Vector search](https://swe.quest/tags/vector-search.md) (Data & databases)
- [PostgreSQL](https://swe.quest/tags/postgres.md) (Data & databases)
- [Search](https://swe.quest/tags/search.md) (Backend & APIs)
- [LLMs](https://swe.quest/tags/llms.md) (AI & ML)

## Prerequisites

- vector embeddings ([easy posts on RAG & retrieval](https://swe.quest/tags/rag.md?difficulty=easy))
- RAG basics ([easy posts on RAG & retrieval](https://swe.quest/tags/rag.md?difficulty=easy))
- PostgreSQL ([easy posts on PostgreSQL](https://swe.quest/tags/postgres.md?difficulty=easy))

## Keywords

Heroku Managed Inference and Agents, pgvector, Cohere Rerank 3.5, Cohere Embed Multilingual, Claude 3.5 Sonnet, Server-Sent Events

## Related posts

- [Building Data-Aware AI Applications with Heroku AI and LlamaIndex](https://swe.quest/articles/building-data-aware-ai-applications-with-heroku-ai-and-llamaindex-8f85403b0aabecc2.md): Heroku Engineering · 2025-08-19 · Medium · 4 min read · RAG & retrieval, Vector search, PostgreSQL, Python, LLMs
  A RAG stack on Heroku pairs LlamaIndex for ingestion, indexing and retrieval with Heroku Managed Inference (Claude 4 Sonnet via an OpenAI-compatible API), Cohere Embed Multilingual for embeddings, and Heroku Postgres with pgvector as the vector store.
- [Build an end-to-end RAG pipeline entirely in psql using pgrag and DeepSeek](https://swe.quest/articles/build-an-end-to-end-rag-pipeline-entirely-in-psql-using-pgrag-and-deepseek-250dc9ab3281f7d0.md): Neon · 2025-01-30 · Medium · 9 min read · RAG & retrieval, PostgreSQL, Vector search, LLMs
  pgrag, Neon's open-source Postgres extension, lets you build a complete RAG pipeline inside psql.
- [Storing OpenAI embeddings in Postgres with pgvector](https://swe.quest/articles/storing-openai-embeddings-in-postgres-with-pgvector-19a5d03614f86fc6.md): Supabase · 2023-02-06 · Medium · 11 min read · Vector search, PostgreSQL, RAG & retrieval, LLMs
  pgvector adds a vector data type and distance operators (Euclidean \<-\>, negative inner product \<#\>, cosine \<=\>) to Postgres, so OpenAI text-embedding-ada-002 embeddings (1536 dimensions) can be stored and queried for similarity directly in the database.
- [Run Embedding Models and Unlock Semantic Search with Docker Model Runner](https://swe.quest/articles/run-embedding-models-and-unlock-semantic-search-with-docker-model-runner-9d62d61c93466830.md): Docker · 2025-12-01 · Medium · 6 min read · Vector search, Inference & serving, Search, RAG & retrieval, Containers
  Docker Model Runner can serve embedding models locally, so semantic search and RAG pipelines run without sending private data to a hosted API and without per-call costs.
- [Neon Docs search is now built on Neon](https://swe.quest/articles/neon-docs-search-is-now-built-on-neon-6358bcc8a0cf6214.md): Neon · 2026-10-26 · Medium · 6 min read · Search, PostgreSQL, Vector search, Caching, AI agents
  Neon's docs search now runs entirely on its own stack: Lakebase Postgres with the lakebase\_vector (pgvector-compatible ANN) and lakebase\_text (BM25) extensions, a Hono API on Neon Functions, and Neon AI Gateway for embeddings and reranking.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
