SOLR-6584 Export handler causes bug in prefetch with very small indexes.

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1635539 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Joel Bernstein 2014-10-30 16:44:11 +00:00
parent 347e4447eb
commit 0a27b98333
3 changed files with 27 additions and 3 deletions

View File

@ -26,6 +26,7 @@ import org.apache.solr.common.util.NamedList;
import org.apache.solr.request.SolrQueryRequest;
import org.apache.solr.common.params.SolrParams;
import java.io.IOException;
import java.util.Map;
import java.util.Set;
@ -147,10 +148,11 @@ public class ExportQParserPlugin extends QParserPlugin {
}
private ScoreDoc[] getScoreDocs(int howMany) {
ScoreDoc[] docs = new ScoreDoc[howMany];
ScoreDoc[] docs = new ScoreDoc[Math.min(totalHits, howMany)];
for(int i=0; i<docs.length; i++) {
docs[i] = new ScoreDoc(i,0);
}
return docs;
}
@ -161,9 +163,11 @@ public class ExportQParserPlugin extends QParserPlugin {
Map context = req.getContext();
context.put("export", sets);
context.put("totalHits", totalHits);
}
return new TopDocs(totalHits, getScoreDocs(howMany), 0.0f);
ScoreDoc[] scoreDocs = getScoreDocs(howMany);
assert scoreDocs.length <= totalHits;
return new TopDocs(totalHits, scoreDocs, 0.0f);
}
public void setScorer(Scorer scorer) throws IOException {

View File

@ -34,6 +34,20 @@
<str name="distrib">false</str>
</lst>
<query>
<enableLazyFieldLoading>true</enableLazyFieldLoading>
<queryResultWindowSize>20</queryResultWindowSize>
<queryResultMaxDocsCached>200</queryResultMaxDocsCached>
<documentCache class="solr.LRUCache"
size="512"
initialSize="512"
autowarmCount="0"/>
</query>
<arr name="components">
<str>query</str>

View File

@ -140,5 +140,11 @@ public class TestSortingResponseWriter extends SolrTestCaseJ4 {
s = h.query(req("q", "id:(1 2 3)", "qt", "/export", "fl", "intdv", "sort", "doubledv desc"));
assertEquals(s, "{\"numFound\":3, \"docs\":[{\"intdv\":3},{\"intdv\":1},{\"intdv\":2}]}");
s = h.query(req("q", "id:100000", "qt", "/export", "fl", "intdv", "sort", "doubledv desc"));
assertEquals(s, "{\"numFound\":0, \"docs\":[]}");
}
}