如何在不指明“top n”的情况下搜索 Lucene.NET达到极限了吗?
Lucene 中有几个 IndexSearcher.Search 方法的重载。其中一些需要“前 n 个点击”参数,有些则不需要(这些已过时,将在 Lucene.NET 3.0 中删除)。
那些需要“top n”参数的参数实际上会导致整个可能的结果范围的内存预分配。因此,当您甚至无法大致估计返回结果的数量时,唯一的机会是传递一个随机的大数字以确保返回所有查询结果。这会导致严重的内存压力和 LOH 碎片造成的泄漏。
有没有一种官方的、不过时的方法来搜索而不传递“top n”参数?
预先感谢各位。
There are several overloads of IndexSearcher.Search method in Lucene. Some of them require "top n hits" argument, some don't (these are obsolete and will be removed in Lucene.NET 3.0).
Those, which require "top n" argument actually cause memory preallocation for this entire posible range of results. So when you're in situation when you can't even approximately estimate count of results returned, the only opportunity is to pass a random large number to ensure that all query results will be returned. This causes severe memory pressure and leaks due to LOH fragmentation.
Is there an oficial not outdated way to search without passing "top n" argument?
Thanks in advance, guys.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我使用 Lucene.NET 2.9.2 作为这个答案的参考点。
您可以构建一个自定义收集器,并将其传递给搜索重载之一。
I'm using Lucene.NET 2.9.2 as reference point for this answer.
You could build a custom collector which you pass to one of the search overloads.