在 Lucene 的 Impact 概念(出现在 `ImpactsEnum` / `Impact` 对象里)中:
字段 含义
freq 当前 term 在该文档中出现了多少次(即词频 term frequency)。
norm 当前 文档在该字段中的长度因子(即之前 norms 里保存的压缩长度值,用来归一化打分)。
---
举个例子
文档 7:
- 字段 `title` 内容:`"lucene lucene search"`
- 分词后:`lucene`(2 次)、`search`(1 次)
- 对 term `"lucene"` 的 `Impact`
- freq = 2(出现了 2 次)
- norm = 压缩后的字段长度 3(3 个 token)
---
一句话
- freq → term 在文档里的出现次数
- norm → 文档在该字段的总 token 数(压缩后的长度因子)
/** Get the set of competitive freq and norm pairs, ordered by increasing freq and norm. */
public Collection<Impact> getCompetitiveFreqNormPairs() {
List<Impact> impacts = new ArrayList<>();
int maxFreqForLowerNorms = 0;
for (int i = 0; i < maxFreqs.length; ++i) {
int maxFreq = maxFreqs[i];
if (maxFreq > maxFreqForLowerNorms) {
impacts.add(new Impact(maxFreq, (byte) i));
maxFreqForLowerNorms = maxFreq;
}
}
if (otherFreqNormPairs.isEmpty()) {
// Common case: all norms are bytes
return impacts;
}
TreeSet<Impact> freqNormPairs = new TreeSet<>(this.otherFreqNormPairs);
for (Impact impact : impacts) {
add(impact, freqNormPairs);
}
return Collections.unmodifiableSet(freqNormPairs);
}
这段代码的作用是:
把当前 term 所有可能出现的 “最大词频 + 对应 norm” 组合,按 freq 升序、norm 升序整理成一条紧凑的 “上限表”(Impact 列表),
供 Block-Max WAND 等跳表算法 在查询时快速判断 “剩下这些文档再也不可能超过当前阈值”,从而提前剪枝、加速 Top-k 检索。
-

最低0.47元/天 解锁文章
1132

被折叠的 条评论
为什么被折叠?



