This is a sample challenge to help candidates get familiar with the setup and testing environment used in our solution engineering assessments.
Implement a search function that can quickly find keywords within a collection of documents. Your function should return matching documents sorted by relevance score.
export function search(
documents: Array<{id: string, content: string}>,
keyword: string
): Array<{id: string, score: number}>The function needs to:
- Find documents containing the search keyword
- Calculate relevance scores for matching documents
- Return results sorted by score (highest first)
- Handle case-insensitive matching
- Work efficiently with large document sets
npm install
npm testnpm test # Run all tests
npm run test:watch # Watch mode for developmentGenerate larger datasets for performance testing:
npm run generate-data # 1,000 documents
npm run generate-data 5000 # 5,000 documentsThe current implementation returns an empty array. Your job is to make the tests pass.
This sample challenge helps you practice with TypeScript, Vitest, and our testing patterns before tackling the real assessment challenges.