MCPcopy
hub / github.com/github/awesome-copilot / search

Method search

website/src/scripts/search.ts:46–72  ·  view source on GitHub ↗

* Search items with fuzzy matching

(query: string, options: SearchOptions = {})

Source from the content-addressed store, hash-verified

44 * Search items with fuzzy matching
45 */
46 search(query: string, options: SearchOptions = {}): T[] {
47 const {
48 fields = ["title", "description", "searchText"],
49 limit = 50,
50 minScore = 0,
51 } = options;
52
53 if (!query || query.trim().length === 0) {
54 return this.items.slice(0, limit);
55 }
56
57 const normalizedQuery = query.toLowerCase().trim();
58 const queryWords = normalizedQuery.split(/\s+/);
59 const results: Array<{ item: T; score: number }> = [];
60
61 for (const item of this.items) {
62 const score = this.calculateScore(item, queryWords, fields);
63 if (score > minScore) {
64 results.push({ item, score });
65 }
66 }
67
68 // Sort by score descending
69 results.sort((a, b) => b.score - a.score);
70
71 return results.slice(0, limit).map((r) => r.item);
72 }
73
74 /**
75 * Calculate match score for an item

Callers 15

get_github_remoteFunction · 0.80
82248Function · 0.80
47956Function · 0.80
_is_structure_sectionFunction · 0.80
validate_tourFunction · 0.80
queryMethod · 0.80
extract_req_patternFunction · 0.80
_parse_coversFunction · 0.80
_bug_primary_requirementFunction · 0.80
file_containsFunction · 0.80

Calls 1

calculateScoreMethod · 0.95

Tested by

no test coverage detected