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";