knowledgesdk.com/glossary/semantic-search
RAG & Retrievalbeginner

Also known as: vector search, meaning-based search

Semantic Search

A search approach that finds results based on meaning and intent rather than exact keyword matching.

What Is Semantic Search?

Semantic search finds documents based on the meaning of a query rather than the literal words it contains. A user searching for "how to cancel my account" will find results about "unsubscribe," "delete my profile," and "stop my subscription" — even if none of those pages use the phrase "cancel my account."

This is in contrast to keyword search, which requires the query terms to appear verbatim in the document.

How Semantic Search Works

  1. At index time, each document (or chunk) is passed through an embedding model, producing a vector
  2. At query time, the query is embedded with the same model
  3. The vector database finds the stored vectors most similar to the query vector (nearest-neighbor search)
  4. The associated documents are returned ranked by similarity score
Query: "cancel my account"
         ↓ embed
Query Vector: [0.12, -0.87, 0.43, ...]
         ↓ ANN search
Results:
  1. "How to unsubscribe" (similarity: 0.94)
  2. "Deleting your profile" (similarity: 0.91)
  3. "Billing cancellation policy" (similarity: 0.88)

Semantic Search vs Keyword Search

Keyword Search Semantic Search
Matches on Exact terms Meaning / intent
Handles synonyms No Yes
Handles typos Partially Yes (embedding is robust)
Handles paraphrases No Yes
Works without training data Yes Requires embedding model
Fast for large corpora Yes (inverted index) Requires ANN index

Similarity Metrics

The most common distance functions:

  • Cosine similarity — measures the angle between vectors; insensitive to vector magnitude. Most common for text.
  • Dot product — similar to cosine but sensitive to magnitude; useful when embeddings are normalized.
  • Euclidean distance (L2) — measures absolute distance; less common for text embeddings.

Limitations of Pure Semantic Search

  • Vocabulary mismatch is solved, but specificity can suffer — "Python" (the language) and "python" (the snake) may be confused depending on context
  • Rare proper nouns — a product code like SKU-4829-X may not embed meaningfully
  • Short queries — very short queries produce noisy embeddings with high variance
  • Recall on exact terms — keyword search reliably finds exact matches; semantic search may miss them

These limitations are why hybrid search (semantic + keyword) is preferred in production.

Semantic Search with KnowledgeSDK

POST /v1/search runs semantic search over all knowledge items indexed for your API key:

curl -X POST https://api.knowledgesdk.com/v1/search \
  -H "x-api-key: knowledgesdk_live_..." \
  -H "Content-Type: application/json" \
  -d '{
    "query": "how do I export my data?",
    "limit": 5
  }'

KnowledgeSDK uses Typesense under the hood, which combines vector search with BM25 keyword scoring — giving you hybrid retrieval without additional configuration.

When to Use Semantic Search

Semantic search is the right choice when:

  • Users phrase questions naturally and unpredictably
  • Your content uses varied vocabulary (synonyms, abbreviations, paraphrases)
  • You need to retrieve conceptually related content, not just keyword matches
  • You are building a RAG pipeline where retrieved context feeds an LLM

Related Terms

RAG & Retrievalbeginner
Embedding
A dense numerical vector representation of text, images, or other data that captures semantic meaning in a high-dimensional space.
RAG & Retrievalbeginner
Vector Database
A specialized database that stores high-dimensional embedding vectors and enables fast similarity search.
RAG & Retrievalintermediate
Hybrid Search
A retrieval strategy that combines dense vector search with sparse keyword search (like BM25) to improve recall and precision.
RAG & Retrievalbeginner
Cosine Similarity
A metric that measures the angle between two vectors, commonly used to compare how semantically similar two embeddings are.
Semantic MemorySitemap

Try it now

Build with Semantic Search using one API.

Extract, index, and search any web content. First 1,000 requests free.

GET API KEY →
← Back to glossary