Fix PageTool to work with distributed query response also

git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@771133 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Erik Hatcher 2009-05-03 22:38:03 +00:00
parent 46cee7fa27
commit 5383ab17b3
1 changed files with 12 additions and 5 deletions

View File

@ -18,6 +18,7 @@
package org.apache.solr.request;
import org.apache.solr.search.DocSlice;
import org.apache.solr.common.SolrDocumentList;
public class PageTool {
private long start;
@ -33,11 +34,17 @@ public class PageTool {
results_per_page = new Integer(rows);
}
DocSlice doc_slice = (DocSlice) response.getValues().get("response");
if (doc_slice != null) {
results_found = doc_slice.matches();
start = doc_slice.offset();
Object docs = response.getValues().get("response");
if (docs != null) {
if (docs instanceof DocSlice) {
DocSlice doc_slice = (DocSlice) docs;
results_found = doc_slice.matches();
start = doc_slice.offset();
} else {
SolrDocumentList doc_list = (SolrDocumentList) docs;
results_found = doc_list.getNumFound();
start = doc_list.getStart();
}
}
page_count = (int) Math.ceil(results_found / (double) results_per_page);