AI Engineering

How to Design Semantic Search Systems with Vectors for Business Data

Short answer

To design semantic search for business data, turn each meaningful record or document section into text, convert it into vector embeddings, and store them with metadata in a vector-capable index. At query time, run keyword and vector search together (hybrid search), rerank the top results, filter by the user's permissions, and measure quality against a golden set of real queries. Retrieval design and evaluation matter far more than the choice of vector database.

Almost every company I work with has the same problem in a different costume. Support agents can't find the right policy. Category managers can't find similar products. Sales can't find the clause they negotiated last year. The data exists; the search box just doesn't understand what people mean.

Vector-based semantic search fixes much of this, but the gap between a weekend demo and a system a business relies on is wide. This guide is the blueprint I teach to analysts and engineering teams: the reference architecture, eight design steps with code, the evaluation metrics that tell you whether it actually works, and the mistakes I see most often.

If you're new to the wider landscape, start with AI vs Generative AI vs Agentic AI.


Semantic search is a retrieval method that finds results by meaning rather than exact word matches. Text (or images) is converted into vectors called embeddings, and the system returns the items whose vectors are closest to the query's vector.

An embedding model places similar meanings near each other in a high-dimensional space. "Refund for a damaged parcel", "my order arrived broken" and "replacement for defective item" end up close together, even though they share almost no words. Keyword search would treat them as unrelated.

Keyword search vs semantic search for the query "my order arrived broken": keyword search returns 0 results, while semantic search places the query vector next to refund, return-policy and replacement documents in the embedding space, away from delivery tracking and billing clusters.
The same customer query, two engines. Keyword search finds no matching words; semantic search finds the documents that mean the same thing. Tap to enlarge.
Keyword search (BM25) Semantic (vector) search
Matches on Exact terms and their frequency Meaning, via embedding similarity
Handles synonyms Only with manual synonym lists Yes, naturally
Handles SKUs, IDs, codes Very well Poorly on its own
Explainability High: you can see which words matched Lower: similarity scores are opaque
Best for Known-item lookups, exact phrases Natural-language questions, discovery

The practical lesson: business search almost always needs both. We'll design for that from the start.

Why is semantic search on business data harder?

Tutorials embed a folder of clean PDFs. Real business data is different in five ways that shape every design decision:

  • It's mixed. Product tables, CRM records, support tickets, contracts, wikis and spreadsheets, often describing the same entity.
  • It's full of identifiers. Order IDs, SKUs, policy numbers and employee codes that pure vector search handles badly.
  • It's permissioned. An HR document must never appear for the wrong user, no matter how relevant it is.
  • It changes. Prices, stock, policies and ticket statuses go stale within hours or days.
  • It uses internal language. Acronyms, team nicknames and, in India especially, Hinglish or transliterated queries that general-purpose models may not have seen.

A design that ignores any one of these will look great in the demo and disappoint in production.

What does a semantic search architecture look like?

A production semantic search system has two pipelines: an indexing pipeline that runs whenever data changes, and a query pipeline that runs on every search.

INDEXING PIPELINE (batch or streaming)
  Sources ──► Extract & clean ──► Model as documents ──► Chunk
  (DB, CRM,      (dedupe, strip       (rows → text,          │
   docs, tickets) boilerplate)         attach metadata)       ▼
                                                    Embed ──► Vector + keyword index
                                                              (with metadata & ACLs)

QUERY PIPELINE (every search, ~100–500 ms budget)
  User query ──► Understand ──► Hybrid retrieve ──► Permission ──► Rerank ──► Results
                 (normalise,     (BM25 + vectors,     filter         (cross-     or RAG
                  detect IDs,     top 50–100 each)    (pre-filter)    encoder)    answer
                  filters)
                                                    ▲
                     Logging, evaluation & feedback ─┘

Every box is a decision. The next section walks through them in the order you should make them.

How do you design a semantic search system, step by step?

Follow these eight steps in order. Teams that start at step 5 (choosing a vector database) usually end up rebuilding.

Step 1: Define the queries and what "good" looks like

Before any technology, collect 50 to 200 real queries from search logs, support transcripts or interviews. For each, record which documents or records are correct. This is your golden set, and it is the single most valuable asset in the project.

Then classify the queries, because each type needs different handling:

  • Known-item: "invoice INV-20431", "SKU 88213". Keyword search wins.
  • Descriptive: "waterproof hiking shoes for wide feet". Semantic search wins.
  • Question: "what's our refund window for damaged items?". Semantic search, often followed by RAG.
  • Analytical: "how many returns last quarter in Pune?". Not a search problem. Route it to SQL.

Write down the success target, for example "the correct document appears in the top 5 for 90% of golden queries", so you know when you're done.

Step 2: Model your business data as searchable documents

Vector search works on text, so structured records need to be serialised into short, descriptive documents. Pick the entity users actually search for (product, ticket, contract, supplier) and write a template:

def product_to_document(p: dict) -> dict:
    text = (
        f"{p['name']} by {p['brand']}. Category: {p['category']}. "
        f"{p['description']} Material: {p['material']}. "
        f"Suitable for: {', '.join(p['use_cases'])}."
    )
    return {
        "id": p["sku"],
        "text": text,                      # what gets embedded
        "metadata": {                      # what gets filtered, never embedded
            "sku": p["sku"],
            "category": p["category"],
            "price_inr": p["price_inr"],
            "in_stock": p["in_stock"],
            "region": p["region"],
            "allowed_groups": p["allowed_groups"],
            "updated_at": p["updated_at"],
        },
    }

Two rules make this work:

  1. Embed descriptive fields; filter on factual ones. Price, stock, dates and region belong in metadata, where they can be filtered exactly. Embedding "₹2,499" teaches the model nothing useful.
  2. Include context a human would need. A ticket chunk that says "it failed again" is useless; prefix it with the product, issue category and customer segment.

Step 3: Chunk at the right grain

Long documents must be split into chunks small enough to embed precisely but large enough to carry meaning.

Content type Recommended chunking Why
Product / CRM records One record = one chunk The entity is already the natural unit
Policies, manuals, wikis By heading, 200–500 tokens, 10–15% overlap Sections map to answerable questions
Contracts By clause, with contract name and party prepended Users ask about specific clauses
Support tickets / chats Problem summary + resolution, not the raw thread Raw threads are noisy and repetitive
Spreadsheets Row or row-group with column headers repeated Headers give each value its meaning

A technique that consistently helps: prepend a short context line to every chunk, such as the document title and section path ("Returns Policy › Damaged Items › Electronics"). It costs a few tokens and makes chunks far easier to retrieve correctly.

Step 4: Choose an embedding model

Don't pick from a leaderboard alone. Shortlist two or three models and test them on your golden set. Judge on:

  • Retrieval quality on your queries, including jargon and acronyms.
  • Language coverage. If users type Hindi, Hinglish or regional languages, you need a multilingual model, and you need those queries in your golden set.
  • Data residency and privacy. Hosted APIs (from providers such as OpenAI, Cohere, Google or Voyage) are easy; open-weight models (such as the BGE, E5 or GTE families) can run inside your own cloud when data can't leave.
  • Dimensions and cost. Larger vectors cost more to store and search. Many modern models let you truncate dimensions with modest quality loss, which is worth testing at scale.
  • Query vs document modes. Some models expect different prefixes or input types for queries and passages. Getting this wrong silently hurts quality.

Lock the model version. Vectors from different models (or versions) are not comparable, so a model change means re-embedding everything.

Step 5: Pick a vector store and index

The best vector store is usually the one closest to where your data and team already are.

Option Good fit when Watch out for
PostgreSQL + pgvector Data is in Postgres; up to millions of vectors; you want SQL joins and filters Tuning needed at very large scale
Elasticsearch / OpenSearch You already run keyword search and want hybrid in one engine Operational overhead, memory sizing
Managed vector DBs (Pinecone, Weaviate, Qdrant, Milvus/Zilliz) Large scale, high QPS, multi-tenancy, minimal ops Another system to secure, sync and pay for
Warehouse vector search (BigQuery, Snowflake, Databricks) Analytics-heavy use cases, batch similarity, data already in the warehouse Latency may not suit interactive search

For the index itself, HNSW is the common default: fast, accurate approximate nearest-neighbour search at the cost of memory. IVF-style indexes and quantisation trade a little recall for much lower memory at large scale. Whatever you choose, measure recall of the approximate index against exact search on a sample; don't assume it.

Step 6: Combine keyword and vector search (hybrid)

Hybrid search runs a keyword (BM25 or full-text) query and a vector query in parallel and merges the results. It's the single biggest quality upgrade for business data, because it covers both "SKU 88213" and "shoes that won't hurt on long walks".

Here's a minimal version in PostgreSQL with pgvector:

-- One-time setup
CREATE EXTENSION IF NOT EXISTS vector;

CREATE TABLE chunks (
  id             text PRIMARY KEY,
  doc_id         text,
  content        text,
  embedding      vector(1024),
  tsv            tsvector GENERATED ALWAYS AS (to_tsvector('english', content)) STORED,
  allowed_groups text[],
  category       text,
  updated_at     timestamptz
);
CREATE INDEX ON chunks USING hnsw (embedding vector_cosine_ops);
CREATE INDEX ON chunks USING gin (tsv);

-- Vector leg: top 50 by cosine distance, permission-filtered
SELECT id FROM chunks
WHERE allowed_groups && :user_groups
ORDER BY embedding <=> :query_embedding
LIMIT 50;

-- Keyword leg: top 50 by full-text rank, same filter
SELECT id FROM chunks
WHERE allowed_groups && :user_groups
  AND tsv @@ websearch_to_tsquery('english', :query_text)
ORDER BY ts_rank_cd(tsv, websearch_to_tsquery('english', :query_text)) DESC
LIMIT 50;

Merge the two lists with Reciprocal Rank Fusion (RRF), which uses rank positions rather than raw scores, so you don't have to normalise BM25 and cosine scores onto the same scale:

def reciprocal_rank_fusion(result_lists, k=60):
    """Merge ranked lists of IDs. Items ranked high in any list rise to the top."""
    scores = {}
    for results in result_lists:
        for rank, doc_id in enumerate(results, start=1):
            scores[doc_id] = scores.get(doc_id, 0.0) + 1.0 / (k + rank)
    return sorted(scores, key=scores.get, reverse=True)

merged = reciprocal_rank_fusion([vector_ids, keyword_ids])[:50]

Also add a small query-understanding step in front: if the query matches an ID pattern (such as INV-\d+), do an exact lookup first; if it mentions a filterable fact ("under ₹3,000", "in Bengaluru"), extract it into a metadata filter instead of hoping the embedding captures it.

Step 7: Rerank, filter and enforce permissions

Reranking takes the top 50 or so merged candidates and re-scores each one against the query with a more expensive cross-encoder model, which reads the query and passage together. It typically lifts the quality of the top 5 noticeably, for a latency cost of tens to a few hundred milliseconds. Hosted and open-source rerankers are both widely available.

Then apply business rules as a final layer: boost in-stock items, demote expired policies, prefer the latest document version, or diversify so the top 10 aren't five chunks of the same PDF.

Permissions are not a ranking feature; they are a hard filter. Three rules:

  1. Store ACL metadata on every chunk (groups, roles, tenant, region), synced from the source system.
  2. Filter inside the retrieval query (pre-filtering), as in the SQL above. Filtering after retrieval can leak information through counts or snippets and can return empty pages.
  3. Never rely on an LLM to "not mention" restricted content. If it was retrieved, assume it can leak.

Step 8: Evaluate, then operate

Measure offline before launch and online after it.

Metric What it tells you When
Recall@k Is the right result anywhere in the top k? Offline, on the golden set
MRR How high is the first correct result? Offline
nDCG@10 Quality of the whole ranking when relevance is graded Offline
Zero-result rate How often users get nothing useful Online
Click-through on top 3 Whether results look right to users Online
Reformulation rate How often users rephrase because the first try failed Online
Task outcome Tickets resolved, add-to-cart, time-to-answer Online: the metric the business cares about

Run every change (chunk size, model, reranker, weights) against the golden set before shipping it. Then plan for operations:

  • Freshness: incremental re-indexing on change events, with a target lag (for example, prices within 15 minutes, policies within a day).
  • Deletions: when a source record is deleted or its permissions change, the chunk must update too. This is the most commonly forgotten pipeline.
  • Versioning: keep the embedding model, chunking config and index version together, and switch indexes with an alias so you can roll back.
  • Latency budget: split it across steps (for example, embedding 30 ms, retrieval 50 ms, reranking 150 ms) and cache embeddings of frequent queries.
  • Cost: embedding is a one-off per chunk plus updates; reranking and LLM calls are per query. Model both before scaling.

What are the most common semantic search mistakes?

  • Vector-only search. Users type IDs and names; pure semantic search misses them. Go hybrid.
  • No golden set. Without one, every change is a matter of opinion and regressions go unnoticed.
  • Embedding everything raw. Boilerplate, navigation text, email signatures and duplicate versions pollute results. Clean before you embed.
  • Using vectors for numbers. "Total sales last month" is a SQL question. Route analytical queries to a database or a text-to-SQL agent; see Agentic AI for Data Analytics.
  • Post-filtering permissions. It leaks and it breaks pagination. Filter inside the query.
  • Forgetting deletes and updates. Stale chunks of withdrawn policies are worse than no result.
  • Mixing embedding models in one index. Vectors from different models are meaningless to compare.
  • Choosing the database first. The vector store is rarely the bottleneck. Data modelling, chunking and evaluation are.

How does semantic search relate to RAG and AI agents?

Semantic search is the retrieval layer underneath retrieval-augmented generation (RAG) and most AI agents. In RAG, the top results from your search system are passed to a large language model, which writes an answer grounded in them. If retrieval returns the wrong passages, the model produces a fluent, confident and wrong answer, so RAG quality is capped by search quality. For how RAG compares with fine-tuning and agentic RAG, see What Is RAG? RAG vs Fine-Tuning vs Agentic RAG.

AI agents go a step further and decide when to search, what to search for and whether to search again. Exposing your search system as a tool, for example through an MCP server, lets any compatible agent use it with your permissions model intact. See MCP Explained for how that works, and How to Build Your First AI Agent to build one.

How do you start a semantic search pilot?

Keep the first version narrow and measurable:

  1. Pick one high-pain use case, such as support agents searching policies or buyers searching a product catalogue.
  2. Collect 100 real queries and label the correct results with two domain experts.
  3. Index one or two sources with clean documents, metadata and ACLs.
  4. Build a keyword-only baseline first, then add vectors, then hybrid, then a reranker, measuring at each step. You'll know exactly what each layer is worth.
  5. Put it in front of 10 to 20 users and track reformulation rate and task outcome, not just likes.
  6. Expand sources only when the metrics and user trust justify it.

Most teams can reach a measurable pilot in four to six weeks this way, and the golden set they build keeps paying off for every future change.

Key takeaways

  • Semantic search finds meaning; keyword search finds exact terms. Business data needs both, so design for hybrid from day one.
  • Start with real queries and a golden set, not with a vector database.
  • Serialise structured records into descriptive text; keep facts like price, stock and dates as filterable metadata.
  • Chunk along natural boundaries and prepend context to every chunk.
  • Rerank the top candidates and enforce permissions as a hard pre-filter.
  • Measure recall@k, MRR and nDCG offline, and task outcomes online. Re-embed fully whenever the model changes.

Frequently asked questions

What is semantic search in simple terms?

Semantic search finds results by meaning rather than exact words. Text is converted into numeric vectors called embeddings, and the system returns the items whose vectors are closest to the query's vector, so a search for "cancel my subscription" can find a document titled "How to end your plan".

Do I need a dedicated vector database for semantic search?

Not always. If your data already lives in PostgreSQL, Elasticsearch, OpenSearch or a cloud warehouse with vector support, start there. Dedicated vector databases make sense at large scale, high query volume or when you need advanced filtering and multi-tenancy features.

Is vector search better than keyword search?

Neither wins alone. Vector search handles synonyms and paraphrases; keyword search handles exact IDs, SKUs, codes and names. Most business search systems perform best with hybrid search that combines both and then reranks the results.

How do I make semantic search work on structured data like tables?

Serialise each meaningful entity, such as a product, customer ticket or contract, into a short descriptive text that includes key fields, embed that text, and keep the original columns as metadata for filtering. Numeric questions like totals and averages should still be answered with SQL, not vector search.

What chunk size should I use for embeddings?

There is no universal number. A common starting point is 200 to 500 tokens with a small overlap, split along natural boundaries such as headings or clauses. Test two or three sizes against your own evaluation set and keep the one with the best recall.

How do I evaluate a semantic search system?

Build a golden set of 50 to 200 real queries with known relevant results, then measure recall at k, MRR and nDCG offline. In production, track zero-result rate, click-through on the top results, query reformulation rate and the task outcome the search supports.

How do I keep semantic search secure for company data?

Store access-control metadata with every chunk and filter on the user's permissions inside the search query, before results are returned. Never rely on the language model to hide documents, and log queries for audit.

What is the difference between semantic search and RAG?

Semantic search retrieves the most relevant items. Retrieval-augmented generation (RAG) passes those retrieved items to a large language model to write an answer. RAG quality depends directly on retrieval quality, so a good semantic search system comes first.

Do I need to re-embed everything when I change the embedding model?

Yes. Vectors from different embedding models are not comparable, so a model change means re-embedding the whole corpus into a new index, evaluating it, and switching traffic only when it beats the current version.

Does semantic search work for Hindi or Hinglish queries?

It can, if you choose a multilingual embedding model and include Hindi, Hinglish and transliterated queries in your evaluation set. Test them explicitly, because performance on mixed-language queries varies widely between models.


Build search your team will trust

The semantic search systems that succeed aren't the ones with the newest vector database. They're the ones built on real queries, clean documents, hybrid retrieval, hard permission filters and an honest evaluation loop. If you want help scoping a pilot, reviewing an architecture or training your team to build it, let's talk.

Next read: MCP (Model Context Protocol) Explained

Book a free call →