On this page
Semantic Understanding
Definition
Semantic understanding is the ability of a search system to comprehend the meaning and context of text beyond literal keyword matching, enabling more intelligent and contextually relevant search results. This technology is commonly implemented alongside Vector Search systems and is a key component of modern Content Indexing strategies.
Technical Explanation
In the context of search APIs, semantic understanding leverages AI models and vector embeddings to transform text into mathematical representations that capture meaning. These representations allow the system to identify conceptually similar content even when exact keywords don't match.
When implemented in vecr.io's search API, semantic understanding processes both search queries and indexed content through neural language models. This creates high-dimensional vector embeddings that preserve semantic relationships, enabling the API to match queries with relevant content based on meaning rather than just text patterns.
The semantic processing happens in two main stages: during content indexing, where documents are transformed into vector embeddings, and during query processing, where user searches are similarly vectorized to enable meaningful comparison.
Practical Applications
- Handling natural language queries by understanding user intent beyond keywords
- Finding conceptually related content even when terminology differs
- Improving search relevance by matching on meaning rather than exact terms
- Supporting synonym detection and concept matching automatically
Code Example
// Type definitions for API responses
interface VecrChunk {
id: number;
content: string;
startIndex: number;
endIndex: number;
fileName: string;
createdAt: string;
vectorizeId: string;
metadata: Record<string, any>;
}
interface SearchResponse {
matches: {
result: {
id: string;
score: number;
namespace: string;
};
chunk: VecrChunk;
}[];
}
interface IndexResponse {
chunks: Array<{
id: number;
content: string;
startIndex: number;
endIndex: number;
fileName: string;
createdAt: string;
vectorizeId: string;
metadata: Record<string, any>;
}>;
file: {
content: string;
fileName: string;
metadata: Record<string, any>;
};
}
// Perform semantic search
async function semanticSearch(query: string, integrationId: string) {
const response = await fetch(`https://api.vecr.io/search/${integrationId}`, {
method: 'POST',
headers: {
'Authorization': `Bearer ${process.env.VECR_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
query,
limit: 10,
includeEmbeddings: false,
preprocessQuery: 'basic'
})
});
if (!response.ok) {
throw new Error(`Search failed: ${response.statusText}`);
}
return await response.json() as SearchResponse;
}
// Index content with semantic understanding
async function indexContent(content: string, fileName: string, integrationId: string) {
const response = await fetch(`https://api.vecr.io/d/${integrationId}/text`, {
method: 'PUT',
headers: {
'Authorization': `Bearer ${process.env.VECR_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
content,
fileName,
metadata: {} // Optional metadata object
})
});
if (!response.ok) {
throw new Error(`Indexing failed: ${response.statusText}`);
}
return await response.json() as IndexResponse;
}
Related Concepts
- Vector Embeddings: Mathematical representations of text that preserve semantic meaning
- Neural Language Models: AI models that power semantic understanding
- Similarity Search: Finding related content based on semantic proximity
- Query Understanding: Interpreting the intent behind user searches
Implementation Tips
- Enable semantic search explicitly when configuring API endpoints
- Index content in smaller chunks to improve semantic matching accuracy
- Consider using field weights to balance semantic vs. keyword matching
- Cache common semantic queries to improve performance
- Monitor semantic search quality through user feedback and relevance metrics
Best Practices
- Pre-process text to remove noise that could affect semantic understanding
- Balance semantic matching with traditional search methods for optimal results
- Update indexed content regularly to maintain semantic accuracy
- Test semantic search with diverse query types to ensure robust performance