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
This commit is contained in:
Martijn van Groningen 2011-07-12 20:16:54 +00:00
parent 766261d06b
commit 9a9d84579e
2 changed files with 16 additions and 6 deletions

View File

@ -585,12 +585,7 @@ public class Grouping {
} }
} }
int len = docsGathered - offset; int len = docsGathered - offset;int[] docs = ArrayUtils.toPrimitive(ids.toArray(new Integer[ids.size()]));
if (offset > len) {
len = 0;
}
int[] docs = ArrayUtils.toPrimitive(ids.toArray(new Integer[ids.size()]));
float[] docScores = ArrayUtils.toPrimitive(scores.toArray(new Float[scores.size()])); float[] docScores = ArrayUtils.toPrimitive(scores.toArray(new Float[scores.size()]));
DocSlice docSlice = new DocSlice(offset, len, docs, docScores, getMatches(), maxScore); DocSlice docSlice = new DocSlice(offset, len, docs, docScores, getMatches(), maxScore);

View File

@ -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 f = "foo_i";
static String f2 = "foo2_i"; static String f2 = "foo2_i";