From f8dd8a6ce38b0fb7ec74b3a359dbecb0d62da35d Mon Sep 17 00:00:00 2001 From: Yonik Seeley Date: Fri, 22 Jul 2011 22:03:54 +0000 Subject: [PATCH] SOLR-2662: fix 'start' handling when a query isn't cached git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1149746 13f79535-47bb-0310-9956-ffa450edef68 --- solr/CHANGES.txt | 6 ++++++ .../src/java/org/apache/solr/search/SolrIndexSearcher.java | 7 +++---- .../src/test/org/apache/solr/search/TestFiltering.java | 4 ++++ 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt index dca1dd264a3..dcd102fc54d 100644 --- a/solr/CHANGES.txt +++ b/solr/CHANGES.txt @@ -369,6 +369,12 @@ Bug Fixes prior to the float value. (Markus Jelsma, hossman) +* SOLR-2662: When Solr is configured to have no queryResultCache, the + "start" parameter was not honored and the documents returned were + 0 through start+offset. (Markus Jelsma, yonik) + + + Other Changes ---------------------- diff --git a/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java b/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java index 513fcab7b09..c60eaeb8f86 100644 --- a/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java +++ b/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java @@ -1151,10 +1151,9 @@ public class SolrIndexSearcher extends IndexSearcher implements SolrInfoMBean { getDocListNC(qr,cmd); //Parameters: cmd.getQuery(),theFilt,cmd.getSort(),0,supersetMaxDoc,cmd.getFlags(),cmd.getTimeAllowed(),responseHeader); } - if (key != null) { - superset = out.docList; - out.docList = superset.subset(cmd.getOffset(),cmd.getLen()); - } + + superset = out.docList; + out.docList = superset.subset(cmd.getOffset(),cmd.getLen()); } // lastly, put the superset in the cache if the size is less than or equal diff --git a/solr/core/src/test/org/apache/solr/search/TestFiltering.java b/solr/core/src/test/org/apache/solr/search/TestFiltering.java index da23d148c6e..f9c3b310c18 100644 --- a/solr/core/src/test/org/apache/solr/search/TestFiltering.java +++ b/solr/core/src/test/org/apache/solr/search/TestFiltering.java @@ -101,6 +101,10 @@ public class TestFiltering extends SolrTestCaseJ4 { ); assertEquals(0, DelegatingCollector.setLastDelegateCount - prevCount); + // test that offset works when not caching main query + assertJQ(req("q","{!cache=false}*:*", "start","2", "rows","1", "sort","val_i asc", "fl","val_i") + ,"/response/docs==[{'val_i':3}]" + ); }