From 5383ab17b34aeadad22ab6ed2ec5d20bba18baa0 Mon Sep 17 00:00:00 2001 From: Erik Hatcher Date: Sun, 3 May 2009 22:38:03 +0000 Subject: [PATCH] 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 --- .../java/org/apache/solr/request/PageTool.java | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/contrib/velocity/src/main/java/org/apache/solr/request/PageTool.java b/contrib/velocity/src/main/java/org/apache/solr/request/PageTool.java index 34b2a984cd6..bfe9513905d 100644 --- a/contrib/velocity/src/main/java/org/apache/solr/request/PageTool.java +++ b/contrib/velocity/src/main/java/org/apache/solr/request/PageTool.java @@ -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);