You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by sh...@apache.org on 2015/10/24 18:11:33 UTC

svn commit: r1710361 - in /lucene/dev/trunk/solr: ./ core/src/java/org/apache/solr/response/transform/ core/src/test/org/apache/solr/response/

Author: shalin
Date: Sat Oct 24 16:11:33 2015
New Revision: 1710361

URL: http://svn.apache.org/viewvc?rev=1710361&view=rev
Log:
SOLR-7993: Raw json output for fields stopped working in 5.3.0 when requested fields do not include the unique key field name

Added:
    lucene/dev/trunk/solr/core/src/test/org/apache/solr/response/TestRawTransformer.java   (with props)
Modified:
    lucene/dev/trunk/solr/CHANGES.txt
    lucene/dev/trunk/solr/core/src/java/org/apache/solr/response/transform/DocTransformer.java
    lucene/dev/trunk/solr/core/src/java/org/apache/solr/response/transform/RawValueTransformerFactory.java

Modified: lucene/dev/trunk/solr/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/CHANGES.txt?rev=1710361&r1=1710360&r2=1710361&view=diff
==============================================================================
--- lucene/dev/trunk/solr/CHANGES.txt (original)
+++ lucene/dev/trunk/solr/CHANGES.txt Sat Oct 24 16:11:33 2015
@@ -291,7 +291,10 @@ Bug Fixes
 
 * SOLR-8189: eTag calculation during HTTP Cache Validation uses unsynchronized WeakHashMap causing
   threads to be stuck in runnable state. (shalin)
-  
+
+* SOLR-7993: Raw json output for fields stopped working in 5.3.0 when requested fields do not include
+  the unique key field name. (Bill Bell, Ryan McKinley via shalin)
+
 Optimizations
 ----------------------
 

Modified: lucene/dev/trunk/solr/core/src/java/org/apache/solr/response/transform/DocTransformer.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/java/org/apache/solr/response/transform/DocTransformer.java?rev=1710361&r1=1710360&r2=1710361&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/java/org/apache/solr/response/transform/DocTransformer.java (original)
+++ lucene/dev/trunk/solr/core/src/java/org/apache/solr/response/transform/DocTransformer.java Sat Oct 24 16:11:33 2015
@@ -63,9 +63,9 @@ public abstract class DocTransformer {
   public abstract void transform(SolrDocument doc, int docid, float score) throws IOException;
 
   /**
-   * When a transformer needs access to fields that are not automaticaly derived from the
+   * When a transformer needs access to fields that are not automatically derived from the
    * input fields names, this option lets us explicitly say the field names that we hope
-   * will be in the SolrDocument.  These fields will be requestd from the 
+   * will be in the SolrDocument.  These fields will be requested from the
    * {@link SolrIndexSearcher} but may or may not be returned in the final
    * {@link QueryResponseWriter}
    * 

Modified: lucene/dev/trunk/solr/core/src/java/org/apache/solr/response/transform/RawValueTransformerFactory.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/java/org/apache/solr/response/transform/RawValueTransformerFactory.java?rev=1710361&r1=1710360&r2=1710361&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/java/org/apache/solr/response/transform/RawValueTransformerFactory.java (original)
+++ lucene/dev/trunk/solr/core/src/java/org/apache/solr/response/transform/RawValueTransformerFactory.java Sat Oct 24 16:11:33 2015
@@ -124,6 +124,11 @@ public class RawValueTransformerFactory
         doc.setField(display, new WriteableStringValue(val));
       }
     }
+
+    @Override
+    public String[] getExtraRequestFields() {
+      return new String[] {this.field};
+    }
   }
   
   public static class WriteableStringValue extends WriteableValue {

Added: lucene/dev/trunk/solr/core/src/test/org/apache/solr/response/TestRawTransformer.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/response/TestRawTransformer.java?rev=1710361&view=auto
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/response/TestRawTransformer.java (added)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/response/TestRawTransformer.java Sat Oct 24 16:11:33 2015
@@ -0,0 +1,71 @@
+package org.apache.solr.response;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.solr.SolrTestCaseJ4;
+import org.apache.solr.common.SolrInputDocument;
+import org.apache.solr.request.SolrQueryRequest;
+import org.junit.After;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Tests Raw JSON output for fields when used with and without the unique key field.
+ *
+ * See SOLR-7993
+ */
+public class TestRawTransformer extends SolrTestCaseJ4 {
+
+  @BeforeClass
+  public static void beforeClass() throws Exception {
+    initCore("solrconfig-doctransformers.xml", "schema.xml");
+  }
+
+  @After
+  public void cleanup() throws Exception {
+    assertU(delQ("*:*"));
+    assertU(commit());
+  }
+
+  @Test
+  public void testCustomTransformer() throws Exception {
+    // Build a simple index
+    int max = 10;
+    for (int i = 0; i < max; i++) {
+      SolrInputDocument sdoc = new SolrInputDocument();
+      sdoc.addField("id", i);
+      sdoc.addField("subject", "{poffL:[{offL:[{oGUID:\"79D5A31D-B3E4-4667-B812-09DF4336B900\",oID:\"OO73XRX\",prmryO:1,oRank:1,addTp:\"Office\",addCd:\"AA4GJ5T\",ad1:\"102 S 3rd St Ste 100\",city:\"Carson City\",st:\"MI\",zip:\"48811\",lat:43.176885,lng:-84.842919,phL:[\"(989) 584-1308\"],faxL:[\"(989) 584-6453\"]}]}]}");
+      sdoc.addField("title", "title_" + i);
+      updateJ(jsonAdd(sdoc), null);
+    }
+    assertU(commit());
+    assertQ(req("q", "*:*"), "//*[@numFound='" + max + "']");
+
+    SolrQueryRequest req = req("q", "*:*", "fl", "subject:[json]", "wt", "json");
+    String strResponse = h.query(req);
+    assertTrue("response does not contain right JSON encoding: " + strResponse,
+        strResponse.contains("\"subject\":[{poffL:[{offL:[{oGUID:\"7"));
+
+    req = req("q", "*:*", "fl", "id,subject", "wt", "json");
+    strResponse = h.query(req);
+    assertTrue("response does not contain right JSON encoding: " + strResponse,
+        strResponse.contains("subject\":[\""));
+  }
+
+}
+