Apache Solr open-source search software
check for null maxScore in JSONResponseWriter
Yonik Seeley6bc6f5a45ab5
diff --git a/src/java/org/apache/solr/request/JSONResponseWriter.java b/src/java/org/apache/solr/request/JSONResponseWriter.javaindex 202e05e40ff..1f49b7790c2 100644--- a/src/java/org/apache/solr/request/JSONResponseWriter.java+++ b/src/java/org/apache/solr/request/JSONResponseWriter.java@@ -522,7 +522,7 @@ class JSONWriter extends TextResponseWriter {writeKey("start",false);writeLong(null,docs.getStart());- if (includeScore) {+ if (includeScore && docs.getMaxScore() != null) {writeMapSeparator();writeKey("maxScore",false);writeFloat(null,docs.getMaxScore());diff --git a/src/test/org/apache/solr/TestDistributedSearch.java b/src/test/org/apache/solr/TestDistributedSearch.javaindex 2301cf23f86..71186d96da8 100755--- a/src/test/org/apache/solr/TestDistributedSearch.java+++ b/src/test/org/apache/solr/TestDistributedSearch.java@@ -453,6 +453,7 @@ public class TestDistributedSearch extends TestCase {// these queries should be exactly ordered and scores should exactly matchquery("q","*:*", "sort",i1+" desc");+ query("q","*:*", "sort",i1+" desc", "fl","*,score");handle.put("maxScore", SKIPVAL);query("q","{!func}"+i1);// does not expect maxScore. So if it comes ,ignore it. NamedListCodec.writeSolrDocumentList()//is agnostic of request params.