-
Lucene results paging
Hi, All! I have some problems with Lucene's search process and it's results, so I hope You could help me.
First one: how should I split results by pages? Now I get search results in such way:
TopDocs topDocs = (is.search(finalQuery, 100000) //For example
and after that I get the needed results in such way:
//for example startPage = 20, endPage = 40
for(int j=startPage; j<stopPage; j++){
doc[j-startPage] = is.doc(topDocs.scoreDocs[j].doc);
}
I think this is a bad approach. How should I optimize my code to make search faster? Is there any possibility to set start and stop pages in search methods?
The second one:
After the search is completed and the results are not sorted are all the results stored in search engine? I mean when I set the max number of docs in method search(finalQuery, 10) equal 10. would Lucene find all relevant docs, then sort them by relevance and select first ten after that? Or does Lucene store some specific information in indices which allows select first 10 most relevant docs without sorting all million (for example) relevant pages?
Thanks in advance.
-
Lucene Results Paging
You're probably better off using Solr, this kind of capability comes with simple query parameters, see
Common Query Parameters - Search by Lucid Imagination
Cheers,
Andrew