我可以让Lucene返回无限数量的搜索结果吗? [英] Can I make Lucene return an unlimited number of search results?

查看:131
本文介绍了我可以让Lucene返回无限数量的搜索结果吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Java 5环境中使用Lucene 3.0.1. 我一直在研究这个问题,但是文档没有给出任何直接的答案.

使用搜索方法

TopFieldDocs    search(Weight weight, Filter filter, int nDocs, Sort sort) 

我总是需要提供最大数量的搜索结果 nDocs .

如果我想获得所有匹配的结果怎么办?感觉将 nDocs 设置为Integer.MAX_VALUE是一种很简单的方法(会导致速度和内存性能下降吗?).

还有其他任何想法吗?

解决方案

您正在使用 解决方案

You are using a search method that returns the top n hits for a query.

There are other (more low-level) methods that do not have the limitation, and it says in the documentation that "applications should only use this if they need all of the matching documents. The high-level search API (search(Query, int)) is usually more efficient, as it skips non-high-scoring hits.".

So if you really need all documents, you can use the low-level API. I doubt that it makes a big difference in performance to passing a really high limit to the high-level API. If you need all documents (and there really are a lot of them), it is going to be slow either way, especially if sorting is involved.

这篇关于我可以让Lucene返回无限数量的搜索结果吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆