java - 为什么 Lucene 使用 maxDoc 而不是 numDocs 来计算术语 idf?

标签 java search lucene

我在 Lucene 的 Similaritypublic 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/

相关文章:

java - 如何将表单数据上传到谷歌应用引擎

java - 字节数组到文件对象而不保存到磁盘

java - 变量不可访问

java - 使用 scala 处理某些 xml 时出现内存不足错误

java - 为什么我的应用程序无法启动(使用 hibernate 搜索配置)?

java - Primefaces PDFExporter 在 PDF 中将非 ASCII 字母显示为垃圾

c# - decimal.Parse 中接受的小数的正则表达式

jquery - jqgrid 搜索上的动态搜索选项

Django 管理员搜索 : how to override the default handler?

ruby-on-rails - Solr (Sunspot) 运行,但不会启动