On this page
Knowledge Base Search
Definition
Knowledge base search is an AI-powered search system designed to efficiently locate and retrieve relevant information from structured collections of documentation, guides, and support content using semantic understanding and vector-based similarity matching.
Technical Explanation
Knowledge base search leverages vector embeddings to transform documentation content into high-dimensional numerical representations that capture semantic meaning. This allows the search system to understand the intent behind user queries and match them with relevant content beyond simple keyword matching.
In vecr.io's implementation, content is automatically indexed through the API, which generates vector embeddings for each document section. These embeddings are stored in a vector database optimized for similarity search operations. When a user queries the system, their search terms are converted into the same vector space, enabling semantic matching against the indexed content.
The API handles multiple content types common in knowledge bases, including markdown documentation, HTML pages, and structured API references. Content is automatically segmented into meaningful chunks and updated incrementally to maintain search freshness.
Practical Applications
- Documentation search with semantic understanding of technical concepts and terminology
- Multi-format content search across various documentation types
- Automated content updates through API-based indexing
- Context-aware search results that understand technical relationships
Code Example
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 VecrWebsiteResponse {
status: string;
}
// Search knowledge base content
async function searchKnowledgeBase(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: 5,
includeEmbeddings: false,
preprocessQuery: "basic",
}),
});
if (!response.ok) {
throw new Error(`Search failed: ${response.statusText}`);
}
return (await response.json()) as SearchResponse;
}
// Submit website for indexing
async function submitWebsite(websiteUrl: string, integrationId: string) {
const response = await fetch(`https://api.vecr.io/w/${integrationId}`, {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.VECR_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
url: websiteUrl,
}),
});
if (!response.ok) {
throw new Error(`Website submission failed: ${response.statusText}`);
}
return (await response.json()) as VecrWebsiteResponse;
}
// Example usage
async function example() {
const integrationId = "your-integration-id";
// Submit documentation website
// Note: Configure crawling settings in the Vecr.io web UI
await submitWebsite("https://docs.example.com", integrationId);
// Search the knowledge base
const results = await searchKnowledgeBase(
"How to implement authentication?",
integrationId
);
console.log("Search results:", results);
}
Related Concepts
- Semantic Understanding: Understanding query intent and context
- Vector Search: Numerical representations of text content
- Content Indexing: Breaking documents into searchable segments and updating content efficiently
Implementation Tips
- Structure content with clear hierarchies and metadata
- Configure appropriate chunk sizes for your content type
- Use consistent formatting and documentation standards
- Implement regular content update schedules
- Monitor search quality metrics and user feedback
- Optimize query parameters for your use case
The system handles technical complexity while exposing a simple API interface, allowing developers to focus on integration rather than search infrastructure.