Skip to content

Commit efc218d

Browse files
fix: searchSkills 使用缓存 IDF 前校验 index 引用一致性,修复测试间歇性失败
1 parent a91653a commit efc218d

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

src/services/skillSearch/localSearch.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ export function searchSkills(
397397
for (const v of freq.values()) if (v > max) max = v
398398
for (const [term, count] of freq) queryTf.set(term, count / max)
399399

400-
const idf = cachedIdf ?? computeIdf(index)
400+
const idf = cachedIndex === index && cachedIdf ? cachedIdf : computeIdf(index)
401401
const queryTfIdf = new Map<string, number>()
402402
for (const [term, tf] of queryTf) {
403403
queryTfIdf.set(term, tf * (idf.get(term) ?? 0))

0 commit comments

Comments
 (0)