Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

Neon 8 min read How-to mediumAdept

BM25 is only as good as your tokens

Lakebase Search's new lakebase_tokenizer extension moves Postgres text-search synonym and stop-word dictionaries from server-side files into SQL tables, so managed and branchable Neon databases can define custom vocabularies with INSERT. Because BM25 only scores the tokens a dictionary produces, unifying variants like k8s/kube/kubernetes, stripping accents and dropping filler words changes both recall and IDF-driven scores. In a support-ticket example, the query 'pg creds zurich' goes from one match to three, and 'please help, kube pods crashing' goes from zero AND-filtered matches to two. Merged synonyms also lower inflated rarity scores for rare spellings.

Related posts

  • CommSync Runs Text, Vector, and Hybrid Search on Postgres with Lakebase Search

    Neon mediumAdept

    CommSync, a unified SMS/email inbox, runs keyword, semantic and hybrid search entirely in Postgres using Neon's Lakebase Search extensions. lakebase_text provides BM25 search with top-K pushdown over tsvector, and lakebase_vector is a pgvector-compatible drop-in with an ANN index. Warm inbox search went from about 19.5s with cold-start GIN to about 18.6ms. The cmd+k palette fuses lexical and semantic results with weighted RRF (k=60, lexical 1.0, semantic 0.8) in two tiers: a 110ms lexical pass per keystroke and a debounced 420ms hybrid pass. Agent RAG uses exact nearest-neighbor on small per-org knowledge bases, with tenancy and permissions expressed as plain WHERE clauses.

  • Neon Docs search is now built on Neon

    Neon mediumAdept

    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. Pages are ingested as markdown via a GitHub Action, chunked by heading, embedded and stored with tsvectors in one table. To fit search-as-you-type latency budgets, full hybrid results (ANN plus BM25 merged with reciprocal rank fusion, then an LLM rerank) are precomputed for common queries and cached, while unseen queries fall back to BM25 only. Cache hits take 1.9 ms and BM25 misses 8.6 ms at p50 on the server, and top-5 hit rate rose from 80% to 94% on 171 real queries.

  • Lakebase Search: vector and BM25 on Neon

    Neon mediumAdept

    Neon's Lakebase Search adds two Postgres extensions, lakebase_vector (IVF partitioning plus RaBitQ quantization, pgvector-compatible) and lakebase_text (a BM25-native index with Block-Max WAND top-K pushdown), designed for Neon's separated compute and object-storage tiers. HNSW's dependent random reads serialize into tens-of-millisecond round trips on object storage, so the new indexes map clusters and postings to contiguous blocks fetched in parallel. RaBitQ's ~32x compression fits a 100M-vector index in under 10GB versus ~300GB for HNSW, with builds 50–100x faster, and indexes persist on object storage so scale-to-zero and copy-on-write branching work without rebuilds. Hybrid search runs as plain SQL in one transaction, and lakebase_ann_prewarm() is available to avoid cold-cache latency.

  • Announcing pg_tiktoken: A Postgres Extension for Fast BPE Tokenization

    Neon mediumAdept

    pg_tiktoken is a Postgres extension on Neon that wraps OpenAI's tiktoken BPE tokenizer, exposing tiktoken_encode (returns token IDs) and tiktoken_count (returns token counts) for encodings such as cl100k_base, p50k_base, p50k_edit and r50k_base or their model names. A practical pattern stores chat message history with a precomputed n_tokens column, then uses a window-function cumulative sum ordered by recency to select the most recent messages that fit within a model's context budget (MAX_HISTORY_TOKENS = model max minus system and completion tokens) before calling gpt-3.5-turbo.

  • pg_search is Available on Neon

    Neon mediumAdept

    ParadeDB's pg_search extension, now available on Neon in AWS regions, adds a Tantivy-powered BM25 inverted index to Postgres, bringing relevance ranking, fuzzy matching, faceting, highlighting and JSON-aware search that native tsvector/GIN full-text search lacks. The BM25 index is a covering index across multiple columns, so filters and aggregations are pushed into a single index scan, and it is MVCC-integrated so new data is searchable on commit without ETL. On a 10-million-row log dataset, it built faster than a GIN index (1.63 vs 2.60 min) but was larger (647 vs 176 MB). It beat a GIN/B-tree-tuned Postgres on every query tested, with the largest gains on ranked top-N, count and filtered queries, e.g. 81 ms vs 38.8 s for BM25-ranked top-10.

The quest for software engineering knowledge.

Look:
Layout: