MCPcopy Create free account
hub / github.com/ZenNotes/zennotes / rankSearchCandidates

Function rankSearchCandidates

apps/desktop/src/main/vault.ts:2218–2236  ·  view source on GitHub ↗
(
  query: string,
  candidates: VaultTextSearchCandidate[],
  limit: number
)

Source from the content-addressed store, hash-verified

2216}
2217
2218function rankSearchCandidates(
2219 query: string,
2220 candidates: VaultTextSearchCandidate[],
2221 limit: number
2222): ScoredVaultTextSearchCandidate[] {
2223 const ranked: ScoredVaultTextSearchCandidate[] = []
2224 for (const candidate of candidates) {
2225 const bodyScore = scoreMatch(query, candidate.lineText)
2226 if (bodyScore <= 0) continue
2227 const titleScore = scoreMatch(query, candidate.title) * 0.18
2228 const pathScore = scoreMatch(query, candidate.path) * 0.1
2229 ranked.push({
2230 ...candidate,
2231 score: bodyScore + titleScore + pathScore
2232 })
2233 }
2234 ranked.sort((a, b) => b.score - a.score)
2235 return ranked.slice(0, limit)
2236}
2237
2238async function runFzfSearch(
2239 query: string,

Callers 2

runFzfSearchFunction · 0.85
searchVaultTextFunction · 0.85

Calls 1

scoreMatchFunction · 0.70

Tested by

no test coverage detected