Cambium
Cambium

Reputation: 19392

Lucene Performance: Retrieve all document from Searcher

I have approximately 10 million objects indexed using NIOFSDirectory.

When I retrieve documents with MatchAllDocsQuery, the performance is significantly worse than other types of Query's, such as BooleanQuery. I ran some tests, performance is approximately 100 times worse.

Since I am only interested in the top n documents anyway, is there a way to retrieve them from the Searcher object without using MatchAllDocsQuery?

I am also considering using WildcardQuery on a random property of the object, but Lucene in Action claims that there are "performance degradations" associated with WildcardQuery.

Suggestions are greatly appreciated!

Upvotes: 1

Views: 3269

Answers (1)

Shashikant Kore
Shashikant Kore

Reputation: 5042

As Yuval pointed in the comment, you have not specified the criteria to get top documents for. If you intend to retrieve random documents, you can simply use IndexReader.document() without going through search at all. If you have some criteria, you can use TermQuery (or the query returned by the QueryParser).

Upvotes: 1

Related Questions