fix distributed search null pointer exception when no docs are matched and debugQuery=true

git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@674549 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Yonik Seeley 2008-07-07 16:37:30 +00:00
parent 7990b2399a
commit e7b1fff87a
2 changed files with 8 additions and 1 deletions

View File

@ -87,7 +87,7 @@ public class DebugComponent extends SearchComponent
public void modifyRequest(ResponseBuilder rb, SearchComponent who, ShardRequest sreq) { public void modifyRequest(ResponseBuilder rb, SearchComponent who, ShardRequest sreq) {
if (!rb.isDebug()) return; if (!rb.isDebug()) return;
// Turn on debug to get explain only only when retrieving fields // Turn on debug to get explain only when retrieving fields
if ((sreq.purpose & ShardRequest.PURPOSE_GET_FIELDS) != 0) { if ((sreq.purpose & ShardRequest.PURPOSE_GET_FIELDS) != 0) {
sreq.purpose |= ShardRequest.PURPOSE_GET_DEBUG; sreq.purpose |= ShardRequest.PURPOSE_GET_DEBUG;
sreq.params.set("debugQuery", "true"); sreq.params.set("debugQuery", "true");
@ -130,6 +130,10 @@ public class DebugComponent extends SearchComponent
} }
explain = HighlightComponent.removeNulls(new SimpleOrderedMap(Arrays.asList(arr))); explain = HighlightComponent.removeNulls(new SimpleOrderedMap(Arrays.asList(arr)));
if (info == null) {
info = new NamedList();
}
int idx = info.indexOf("explain",0); int idx = info.indexOf("explain",0);
if (idx>=0) { if (idx>=0) {
info.setVal(idx, explain); info.setVal(idx, explain);

View File

@ -486,6 +486,9 @@ public class TestDistributedSearch extends TestCase {
query("q","now their fox sat had put","fl","*,score", query("q","now their fox sat had put","fl","*,score",
"debugQuery", "true"); "debugQuery", "true");
query("q","matchesnothing","fl","*,score",
"debugQuery", "true");
query("q","*:*", "rows",100, "facet","true", "facet.field",t1); query("q","*:*", "rows",100, "facet","true", "facet.field",t1);
query("q","*:*", "rows",100, "facet","true", "facet.field",t1,"facet.limit",1); query("q","*:*", "rows",100, "facet","true", "facet.field",t1,"facet.limit",1);
query("q","*:*", "rows",100, "facet","true", "facet.query","quick", "facet.query","all", "facet.query","*:*"); query("q","*:*", "rows",100, "facet","true", "facet.query","quick", "facet.query","all", "facet.query","*:*");