From 9a9d84579e0139115270db6a7624bd60c742cc01 Mon Sep 17 00:00:00 2001 From: Martijn van Groningen Date: Tue, 12 Jul 2011 20:16:54 +0000 Subject: [PATCH] fixed bug when start is bigger than rows and format is simple that zero documents are returned even if there are documents to display. git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1145747 13f79535-47bb-0310-9956-ffa450edef68 --- .../src/java/org/apache/solr/search/Grouping.java | 7 +------ .../test/org/apache/solr/TestGroupingSearch.java | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/solr/core/src/java/org/apache/solr/search/Grouping.java b/solr/core/src/java/org/apache/solr/search/Grouping.java index fd4fe6a2d1c..8d6a003ca7f 100755 --- a/solr/core/src/java/org/apache/solr/search/Grouping.java +++ b/solr/core/src/java/org/apache/solr/search/Grouping.java @@ -585,12 +585,7 @@ public class Grouping { } } - int len = docsGathered - offset; - if (offset > len) { - len = 0; - } - - int[] docs = ArrayUtils.toPrimitive(ids.toArray(new Integer[ids.size()])); + int len = docsGathered - offset;int[] docs = ArrayUtils.toPrimitive(ids.toArray(new Integer[ids.size()])); float[] docScores = ArrayUtils.toPrimitive(scores.toArray(new Float[scores.size()])); DocSlice docSlice = new DocSlice(offset, len, docs, docScores, getMatches(), maxScore); diff --git a/solr/core/src/test/org/apache/solr/TestGroupingSearch.java b/solr/core/src/test/org/apache/solr/TestGroupingSearch.java index 17ce2a12dde..d705e5bba71 100644 --- a/solr/core/src/test/org/apache/solr/TestGroupingSearch.java +++ b/solr/core/src/test/org/apache/solr/TestGroupingSearch.java @@ -199,6 +199,21 @@ public class TestGroupingSearch extends SolrTestCaseJ4 { ); } + @Test + public void testGroupingSimpleFormatStartBiggerThanRows() throws Exception { + assertU(add(doc("id", "1"))); + assertU(add(doc("id", "2"))); + assertU(add(doc("id", "3"))); + assertU(add(doc("id", "4"))); + assertU(add(doc("id", "5"))); + assertU(commit()); + + assertJQ( + req("q", "*:*", "start", "2", "rows", "1", "group", "true", "group.field", "id", "group.main", "true"), + "/response=={'numFound':5,'start':2,'docs':[{'id':'3'}]}" + ); + } + static String f = "foo_i"; static String f2 = "foo2_i";