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
- At index time, each document (or chunk) is passed through an embedding model, producing a vector
- At query time, the query is embedded with the same model
- The vector database finds the stored vectors most similar to the query vector (nearest-neighbor search)
- 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-Xmay 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