SOLR-6029: CollapsingQParserPlugin throws ArrayIndexOutOfBoundsException if elevated doc has been deleted from a segment

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1590865 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Joel Bernstein 2014-04-29 04:43:07 +00:00
parent 5c2e9e8acf
commit 37e44ba41a
2 changed files with 18 additions and 1 deletions

View File

@ -266,7 +266,7 @@ public class CollapsingQParserPlugin extends QParserPlugin {
if(termsEnum.seekExact(ref)) {
docsEnum = termsEnum.docs(liveDocs, docsEnum);
int doc = docsEnum.nextDoc();
if(doc != -1) {
if(doc != DocsEnum.NO_MORE_DOCS) {
//Found the document.
boostDocs.add(doc+docBase);
it.remove();

View File

@ -343,6 +343,23 @@ public class TestCollapseQParserPlugin extends SolrTestCaseJ4 {
params.add("group.field", "id");
assertQ(req(params), "*[count(//doc)=2]");
// delete the elevated docs, confirm collapsing still works
assertU(delI("1"));
assertU(delI("2"));
assertU(commit());
params = new ModifiableSolrParams();
params.add("q", "YYYY");
params.add("fq", "{!collapse field=group_s nullPolicy=collapse}");
params.add("defType", "edismax");
params.add("bf", "field(test_ti)");
params.add("qf", "term_s");
params.add("qt", "/elevate");
assertQ(req(params), "*[count(//doc)=2]",
"//result/doc[1]/float[@name='id'][.='3.0']",
"//result/doc[2]/float[@name='id'][.='6.0']");
}
@Test