Manzar Anjum.

Work/Search and RAG

RAG search over a million records, with keyword lookups under 0.3 seconds

The agents on my platform know only what they can look up. I built the search they depend on: about 1 million business records, found by meaning or by exact wording, with the source attached to every answer.

Role
Design, build and operations
Scale
About 1 million records
Stack
Python, PostgreSQL, pgvector, embeddings, a reranker, Docker
Recordsabout 1 millionVector indexpgvector: by meaningKeyword indexPostgreSQL: exact wordsRerankernewest decision winsAnswer+ sourceKEYWORD LOOKUPbeforeup to 6.6 snowunder 0.3 s
Fig. 02 Two searches over the same records, reranked, answered with the source attachedDiagram

The problem

An agent with a slow search starts every task slowly. An agent with a wrong search acts on something that stopped being true.

Both problems grow with the records. At a million of them, the keyword half of the search could take up to 6.6 seconds for one lookup.

What I built

  • Two searches, one answer.

    Vector search on pgvector finds records that mean the same as the question. Keyword search catches the exact names, part numbers and error messages that vectors miss.

  • The slow half, fixed.

    I moved keyword search into PostgreSQL. A lookup that took up to 6.6 seconds now returns in under 0.3.

  • Ranked, dated and cited.

    A reranker puts the best matches first. When two records disagree, the newer one wins. Every answer names the record and the line it came from.

  • It says when it cannot answer.

    If the index is behind the records, the search refuses instead of answering from stale data. Each business's records are kept apart, so a search for one never returns another's.

  • More than a search box.

    Around the search sit a store of dated facts that knows which decision is in force today, a graph of how the records relate, and a second look when the first matches are weak. The records live in 33 separate collections.

How I know it works

  • Before the switch, the old and the new keyword search answered the same real questions and every match was compared.
  • A probe queries the live search on a schedule and raises an alarm when an answer is slow or missing.
  • Measured over 24 hours on 15 November 2026: 388 of 395 lookups worked, and 359 of the 395 answered within 5 seconds.
  • A new record is searchable after 2 minutes in the median (747 new records that day; 738 within 5 minutes).

In numbers

  • ~1Mrecords searched
  • 6.6sslowest keyword lookup before
  • <0.3skeyword lookup now

My part

I designed the retrieval, did the performance work and run it as part of the agent platform.

  • Python
  • PostgreSQL
  • pgvector
  • Embeddings
  • Reranking