Hello,

I'm trying to implement standard pagination with sorting and faceting, and I 
have some
code like the following:

// Convert user supplied sorts to Lucene Sort, or use Sort.RELEVANCE if none 
provided
Sort sort = ...;
      
FacetsCollector facetsCollector = new FacetsCollector();

TopFieldCollector topFieldCollector = TopFieldCollector.create(
        sort, maxSearchResults, false, false, false);

Collector collector = MultiCollector.wrap(topFieldCollector, facetsCollector);

searcher.search(query, collector);

int start = ...
int howMany = ...;

for (ScoreDoc scoreDoc : topFieldCollector.topDocs(start, howMany).scoreDocs) {
    Document doc = ... // read & process doc
}

My understanding is that we can set maxSearchResults to something 
like # of max pages * # of results per page, and on every request for next page 
we 
are re-computing the full set of matching docs, but then only loading the 
results from 
start to start + howMany.

Question #1

Lets say we are sorting on a field create_date in ascending order, and there 
are 1,000 
documents that match the query, and maxSearchResults is set to 100...

Is the first result guaranteed to be the earliest create_date out of all 1,000 
matching 
documents, or is it only the earliest out of the first 100 that were found?

Question #2

I was originally attempting to use the searchAfter approach keeping track of 
the last 
doc from the previous page. This seems like it would be more efficient, but I 
was kind 
of stuck on how to have a client send back the last doc. 

For example, with a REST API, how would you have the client send something back 
to 
the server that could be turned back into a FieldDoc to submit for the next 
page?

I imagine Solr is doing something like this under the hood with the cursorMark 
feature,
but I'm not familiar with how that relates to searchAfter.

Any thoughts are appreciated.

Thank you,

Bryan



---------------------------------------------------------------------
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