You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ma...@apache.org on 2012/03/27 19:41:18 UTC

svn commit: r1305927 - in /lucene/dev/trunk/solr: CHANGES.txt core/src/java/org/apache/solr/handler/component/QueryComponent.java core/src/test/org/apache/solr/TestDistributedSearch.java

Author: markrmiller
Date: Tue Mar 27 17:41:18 2012
New Revision: 1305927

URL: http://svn.apache.org/viewvc?rev=1305927&view=rev
Log:
SOLR-3214: If you use multiple fl entries rather than a comma separated list, all but the first entry can be ignored if you are using distributed search.
SOLR-3256: Distributed search throws NPE when using fl=score

Modified:
    lucene/dev/trunk/solr/CHANGES.txt
    lucene/dev/trunk/solr/core/src/java/org/apache/solr/handler/component/QueryComponent.java
    lucene/dev/trunk/solr/core/src/test/org/apache/solr/TestDistributedSearch.java

Modified: lucene/dev/trunk/solr/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/CHANGES.txt?rev=1305927&r1=1305926&r2=1305927&view=diff
==============================================================================
--- lucene/dev/trunk/solr/CHANGES.txt (original)
+++ lucene/dev/trunk/solr/CHANGES.txt Tue Mar 27 17:41:18 2012
@@ -1,4 +1,4 @@
-                      Apache Solr Release Notes
+                      Apache Solr Release Notes
 
 Introduction
 ------------
@@ -353,7 +353,9 @@ Bug Fixes
 
 * SOLR-3062: A join in the main query was not respecting any filters pushed
   down to it via acceptDocs since LUCENE-1536. (Mike Hugo, yonik)
-
+  
+* SOLR-3214: If you use multiple fl entries rather than a comma separated list, all but the first
+  entry can be ignored if you are using distributed search. (Tomas Fernandez Lobbe via Mark Miller)
 
 Other Changes
 ----------------------

Modified: lucene/dev/trunk/solr/core/src/java/org/apache/solr/handler/component/QueryComponent.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/java/org/apache/solr/handler/component/QueryComponent.java?rev=1305927&r1=1305926&r2=1305927&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/java/org/apache/solr/handler/component/QueryComponent.java (original)
+++ lucene/dev/trunk/solr/core/src/java/org/apache/solr/handler/component/QueryComponent.java Tue Mar 27 17:41:18 2012
@@ -941,17 +941,10 @@ public class QueryComponent extends Sear
       // we already have the field sort values
       sreq.params.remove(ResponseBuilder.FIELD_SORT_VALUES);
 
-      // make sure that the id is returned for correlation.
-      String fl = sreq.params.get(CommonParams.FL);
-      if (fl != null) {
-         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());
-         }
-      }      
-
+      if(!rb.rsp.getReturnFields().wantsField(uniqueField.getName())) {
+        sreq.params.add(CommonParams.FL, uniqueField.getName());
+      }
+    
       ArrayList<String> ids = new ArrayList<String>(shardDocs.size());
       for (ShardDoc shardDoc : shardDocs) {
         // TODO: depending on the type, we may need more tha a simple toString()?
@@ -979,6 +972,7 @@ public class QueryComponent extends Sear
       SolrDocumentList docs = (SolrDocumentList)srsp.getSolrResponse().getResponse().get("response");
 
       String keyFieldName = rb.req.getSchema().getUniqueKeyField().getName();
+      boolean removeKeyField = !rb.rsp.getReturnFields().wantsField(keyFieldName);
 
       for (SolrDocument doc : docs) {
         Object id = doc.getFieldValue(keyFieldName);
@@ -987,6 +981,9 @@ public class QueryComponent extends Sear
           if (returnScores && sdoc.score != null) {
               doc.setField("score", sdoc.score);
           }
+          if(removeKeyField) {
+            doc.removeFields(keyFieldName);
+          }
           rb._responseDocs.set(sdoc.positionInResponse, doc);
         }
       }

Modified: lucene/dev/trunk/solr/core/src/test/org/apache/solr/TestDistributedSearch.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/TestDistributedSearch.java?rev=1305927&r1=1305926&r2=1305927&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/TestDistributedSearch.java (original)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/TestDistributedSearch.java Tue Mar 27 17:41:18 2012
@@ -204,6 +204,16 @@ public class TestDistributedSearch exten
           "facet.range.start",200, 
           "facet.range.gap",100, 
           "f."+tlong+".facet.range.end",900);
+    
+    //  variations of fl
+    query("q","*:*", "fl","score","sort",i1 + " desc");
+    query("q","*:*", "fl",i1 + ",score","sort",i1 + " desc");
+    query("q","*:*", "fl", i1, "fl","score","sort",i1 + " desc");
+    query("q","*:*", "fl", "id," + i1,"sort",i1 + " desc");
+    query("q","*:*", "fl", "id", "fl",i1,"sort",i1 + " desc");
+    query("q","*:*", "fl",i1, "fl", "id","sort",i1 + " desc");
+    query("q","*:*", "fl", "id", "fl",nint, "fl",tint,"sort",i1 + " desc");
+    query("q","*:*", "fl",nint, "fl", "id", "fl",tint,"sort",i1 + " desc");
 
     stress=0;  // turn off stress... we want to tex max combos in min time
     for (int i=0; i<25*RANDOM_MULTIPLIER; i++) {