mirror of https://github.com/apache/lucene.git
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:
parent
347e4447eb
commit
0a27b98333
|
@ -26,6 +26,7 @@ import org.apache.solr.common.util.NamedList;
|
||||||
import org.apache.solr.request.SolrQueryRequest;
|
import org.apache.solr.request.SolrQueryRequest;
|
||||||
import org.apache.solr.common.params.SolrParams;
|
import org.apache.solr.common.params.SolrParams;
|
||||||
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
@ -147,10 +148,11 @@ public class ExportQParserPlugin extends QParserPlugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
private ScoreDoc[] getScoreDocs(int howMany) {
|
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++) {
|
for(int i=0; i<docs.length; i++) {
|
||||||
docs[i] = new ScoreDoc(i,0);
|
docs[i] = new ScoreDoc(i,0);
|
||||||
}
|
}
|
||||||
|
|
||||||
return docs;
|
return docs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -161,9 +163,11 @@ public class ExportQParserPlugin extends QParserPlugin {
|
||||||
Map context = req.getContext();
|
Map context = req.getContext();
|
||||||
context.put("export", sets);
|
context.put("export", sets);
|
||||||
context.put("totalHits", totalHits);
|
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 {
|
public void setScorer(Scorer scorer) throws IOException {
|
||||||
|
|
|
@ -34,6 +34,20 @@
|
||||||
<str name="distrib">false</str>
|
<str name="distrib">false</str>
|
||||||
</lst>
|
</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">
|
<arr name="components">
|
||||||
<str>query</str>
|
<str>query</str>
|
||||||
|
|
|
@ -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"));
|
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}]}");
|
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\":[]}");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue