Apache Solr open-source search software
SOLR-1587: fl=score same as fl=*,score for distrib search
Yonik Seeleyf1dda28cb88a
diff --git a/CHANGES.txt b/CHANGES.txtindex 02dc26b467b..e6eb8758ae1 100644--- a/CHANGES.txt+++ b/CHANGES.txt@@ -91,7 +91,9 @@ Bug Fixesset when streaming updates, rather than using UTF-8 as the HTTP headersindicated, leading to an encoding mismatch. (hossman, yonik)-didn't specify the character set creating OutputStreamWriter+* SOLR-1587: A distributed search request with fl=score, didn't match+ the behavior of a non-distributed request since it only returned+ the id,score fields instead of all fields in addition to score. (yonik)Other Changesdiff --git a/src/java/org/apache/solr/handler/component/QueryComponent.java b/src/java/org/apache/solr/handler/component/QueryComponent.javaindex 1e077fd52ae..dc32c2c20a2 100644--- a/src/java/org/apache/solr/handler/component/QueryComponent.java+++ b/src/java/org/apache/solr/handler/component/QueryComponent.java@@ -513,10 +513,15 @@ public class QueryComponent extends SearchComponent// we already have the field sort valuessreq.params.remove(ResponseBuilder.FIELD_SORT_VALUES);- // make sure that the id is returned for correlation+ // make sure that the id is returned for correlation.String fl = sreq.params.get(CommonParams.FL);if (fl != null) {- sreq.params.set(CommonParams.FL, fl+','+uniqueField.getName());+ fl = fl.trim();+ // currently, "score" is synonymous with "*,score" so+ // don't add "id" if the fl is empty or "score" or it would change the meaning.+ if (fl.length()!=0 && !"score".equals(fl) && !"*".equals(fl)) {+ sreq.params.set(CommonParams.FL, fl+','+uniqueField.getName());+ }}ArrayList<String> ids = new ArrayList<String>(shardDocs.size());diff --git a/src/test/org/apache/solr/TestDistributedSearch.java b/src/test/org/apache/solr/TestDistributedSearch.javaindex 48ab513f200..d77f596a31b 100755--- a/src/test/org/apache/solr/TestDistributedSearch.java+++ b/src/test/org/apache/solr/TestDistributedSearch.java@@ -619,6 +619,7 @@ public class TestDistributedSearch extends AbstractSolrTestCase {query("q","*:*", "sort",i1+" desc");query("q","*:*", "sort",i1+" asc");query("q","*:*", "sort",i1+" desc", "fl","*,score");+ query("q","*:*", "sort",tlong+" asc", "fl","score"); // test legacy behavior - "score"=="*,score"query("q","*:*", "sort",tlong+" desc");handle.put("maxScore", SKIPVAL);query("q","{!func}"+i1);// does not expect maxScore. So if it comes ,ignore it. JavaBinCodec.writeSolrDocumentList()diff --git a/src/test/org/apache/solr/client/solrj/embedded/JettyWebappTest.java b/src/test/org/apache/solr/client/solrj/embedded/JettyWebappTest.javaindex 17baea1805a..d1fc87a2497 100644--- a/src/test/org/apache/solr/client/solrj/embedded/JettyWebappTest.java+++ b/src/test/org/apache/solr/client/solrj/embedded/JettyWebappTest.java@@ -41,7 +41,9 @@ public class JettyWebappTest extends TestCase@Overridepublic void setUp() throws Exception{- System.setProperty("solr.solr.home", "../../../example/solr");+ System.setPrope++ rty("solr.solr.home", "../../../example/solr");String path = "../../webapp/web";server = new Server(port);