I looking for solution how to cache searching results in Lucene. When i used Solr pagination was much easier
My solr code:
query.setStart(start);
query.setRows(rows);
QueryResponse response = solr.query(query);
Simple wildcard searching it was like 400ms for 1st 100 results and each next page it was like 20-70ms
But when I'm using Lucene each time I have to search again and each page takes 400ms
My Lucene code:
Query query = queryParser.parse(text);
TopScoreDocCollector collector=TopScoreDocCollector.create(1000000);
IndexSearcher = indexSearcher.search(query, collector);TopDocs results =collector.topDocs(start,rows);
for (ScoreDoc scoreDoc : results.scoreDocs) {
Document document = indexSearcher.doc(scoreDoc.doc);
I tried make TopScoreDocCollector and IndexSearcher static but this don't work
Do you have any other solution?