Jon

I ended up adapting your approach. The solution involves keeping a LRU cache of page boundary scoredocs and their respective positions. New positions are added to the cache as new pages are discovered. To cut down on searches, when scrolling backwards and forwards, the search begins from nearest cached position.

Cheers

Jamie

On 2014/06/03, 3:24 PM, Jon Stewart wrote:
With regards to pagination, is there a way for you to cache the
IndexSearcher, Query, and TopDocs between user pagination requests (a
lot of webapp frameworks have object caching mechanisms)? If so, you
may have luck with code like this:

   void ensureTopDocs(final int rank) throws IOException {
     if (StartDocIndex > rank) {
       Docs = Searcher.search(SearchQuery, TOP_DOCS_WINDOW);
       StartDocIndex = 0;
     }
     int len = Docs.scoreDocs.length;
     while (StartDocIndex + len <= rank) {
       StartDocIndex += len;
       Docs = Searcher.searchAfter(Docs.scoreDocs[len - 1],
SearchQuery, TOP_DOCS_WINDOW);
       len = Docs.scoreDocs.length;
     }
   }



---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org
For additional commands, e-mail: java-user-h...@lucene.apache.org

Reply via email to