我在 Lucene 的 Similarity
类 public float idf(Term term, Searcher searcher)
方法 javadoc 上找到了这个:
Note that Searcher.maxDoc() is used instead of IndexReader#numDocs() because also Searcher.docFreq(Term) is used, and when the latter is inaccurate, so is Searcher.maxDoc(), and in the same direction. In addition, Searcher.maxDoc() is more efficient to compute.
这对我来说意义不大。这与 IndexReader 中的文档删除有关吗?
最佳答案
是的,完全正确。每当删除文档(或更新,因为 Lucene 中的更新只是先删除再添加)时,文档将保留在索引中,直到这些段被合并,通常是通过索引优化。它不会被搜索返回,已被删除,但它的术语仍然会影响 idf 评分。
LuceneFAQ 有一些与此相关的信息,特别是在 this answer on deletion 的最后一段中, 和 this addressing maxDoc specifically
关于java - 为什么 Lucene 使用 maxDoc 而不是 numDocs 来计算术语 idf?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16851093/