Documentation Index Fetch the complete documentation index at: https://docs.agentfront.dev/llms.txt
Use this file to discover all available pages before exploring further.
Learn how to perform semantic searches with natural language queries.
Simple Search
const results = await toolIndex . search ( ' reset a billing password ' );
for ( const result of results ) {
console . log ( ` ${ result . metadata . toolName } ( ${ result . score . toFixed ( 2 ) } ) ` );
}
Search Options
const matches = await toolIndex . search ( ' reset a billing password ' , {
topK : 5 , // Maximum results (default: 10)
threshold : 0.45 , // Minimum similarity (default: 0.3)
filter : ( metadata ) => // Metadata filter function
metadata . owner === ' billing ' &&
! metadata . tags . includes ( ' deprecated ' ),
includeVector : false , // Include raw vectors in results
});
Options Reference
Option Type Default Description topKnumber10Maximum results to return thresholdnumber0.3Minimum similarity score (0-1) filterfunction- Filter function for metadata includeVectorbooleanfalseInclude raw vectors in results
Search Results
Each result contains:
src/types/search-result.ts
interface SearchResult < T extends DocumentMetadata > {
id : string ; // Document ID
score : number ; // Similarity score (0-1)
metadata : T ; // Document metadata
text : string ; // Original document text
vector ?: number []; // Embedding vector (if includeVector: true)
}
Understanding Scores
Scores range from 0 to 1:
0.8-1.0 : Very high similarity (nearly identical meaning)
0.6-0.8 : High similarity (strongly related)
0.4-0.6 : Moderate similarity (related concepts)
0.2-0.4 : Low similarity (loosely related)
0.0-0.2 : Very low similarity (probably unrelated)
const results = await db . search ( ' create user account ' );
for ( const result of results ) {
const confidence = result . score >= 0.6 ? ' High '
: result . score >= 0.4 ? ' Medium '
: ' Low ' ;
console . log ( ` ${ result . id } : ${ result . score . toFixed ( 2 ) } ( ${ confidence } ) ` );
}
Error Handling
import { QueryValidationError , VectoriaNotInitializedError } from ' vectoriadb ' ;
try {
const results = await toolIndex . search ( query , { topK : - 1 });
} catch ( error ) {
if ( error instanceof QueryValidationError ) {
console . error ( ' Invalid search parameters: ' , error . message );
} else if ( error instanceof VectoriaNotInitializedError ) {
console . error ( ' Database not initialized ' );
await toolIndex . initialize ();
}
}
Empty Results
Common reasons for empty results:
Threshold too high - Lower the threshold option
No matching documents - Check that documents are indexed
Filter too restrictive - Review your filter function
// Debug: search without filters and low threshold
const results = await db . search ( query , {
threshold : 0.1 ,
topK : 20 ,
// No filter
});
console . log ( ' Found: ' , results . length );
Filtering Filter search results
Thresholds Tune similarity thresholds
Performance Optimize search performance