You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-commits@lucene.apache.org by eh...@apache.org on 2009/05/04 00:38:04 UTC

svn commit: r771133 - /lucene/solr/trunk/contrib/velocity/src/main/java/org/apache/solr/request/PageTool.java

Author: ehatcher
Date: Sun May  3 22:38:03 2009
New Revision: 771133

URL: http://svn.apache.org/viewvc?rev=771133&view=rev
Log:
Fix PageTool to work with distributed query response also

Modified:
    lucene/solr/trunk/contrib/velocity/src/main/java/org/apache/solr/request/PageTool.java

Modified: lucene/solr/trunk/contrib/velocity/src/main/java/org/apache/solr/request/PageTool.java
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/contrib/velocity/src/main/java/org/apache/solr/request/PageTool.java?rev=771133&r1=771132&r2=771133&view=diff
==============================================================================
--- lucene/solr/trunk/contrib/velocity/src/main/java/org/apache/solr/request/PageTool.java (original)
+++ lucene/solr/trunk/contrib/velocity/src/main/java/org/apache/solr/request/PageTool.java Sun May  3 22:38:03 2009
@@ -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 @@
       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);