You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by no...@apache.org on 2019/08/25 23:02:21 UTC

[lucene-solr] branch branch_8x updated (f41b600 -> b7c9a9f)

This is an automated email from the ASF dual-hosted git repository.

noble pushed a change to branch branch_8x
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git.


    from f41b600  SOLR-13650: ned to recompile the test jars with java 8
     new 16a1ef8  SOLR-13699 - maxChars no longer working on CopyField with Javabin
     new b7c9a9f  SOLR-13699 - maxChars no longer working on CopyField with javabin

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 solr/CHANGES.txt                                   |  2 ++
 .../org/apache/solr/update/DocumentBuilder.java    |  4 ++--
 .../test-files/solr/collection1/conf/schema.xml    |  4 ++++
 .../apache/solr/update/DocumentBuilderTest.java    | 25 ++++++++++++++++++++++
 4 files changed, 33 insertions(+), 2 deletions(-)


[lucene-solr] 01/02: SOLR-13699 - maxChars no longer working on CopyField with Javabin

Posted by no...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

noble pushed a commit to branch branch_8x
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git

commit 16a1ef8621dbcd7251281a7182ca4fe49999fd57
Author: Chris Troullis <cp...@gmail.com>
AuthorDate: Sun Aug 25 18:57:17 2019 -0400

    SOLR-13699 - maxChars no longer working on CopyField with Javabin
---
 .../org/apache/solr/update/DocumentBuilder.java    |  4 ++--
 .../test-files/solr/collection1/conf/schema.xml    |  4 ++++
 .../apache/solr/update/DocumentBuilderTest.java    | 25 ++++++++++++++++++++++
 3 files changed, 31 insertions(+), 2 deletions(-)

diff --git a/solr/core/src/java/org/apache/solr/update/DocumentBuilder.java b/solr/core/src/java/org/apache/solr/update/DocumentBuilder.java
index 90694ff..543a4cb 100644
--- a/solr/core/src/java/org/apache/solr/update/DocumentBuilder.java
+++ b/solr/core/src/java/org/apache/solr/update/DocumentBuilder.java
@@ -196,8 +196,8 @@ public class DocumentBuilder {
 
                 // Perhaps trim the length of a copy field
                 Object val = v;
-                if( val instanceof String && cf.getMaxChars() > 0 ) {
-                  val = cf.getLimitedValue((String)val);
+                if( val instanceof CharSequence && cf.getMaxChars() > 0 ) {
+                    val = cf.getLimitedValue(val.toString());
                 }
 
                 addField(out, destinationField, val,
diff --git a/solr/core/src/test-files/solr/collection1/conf/schema.xml b/solr/core/src/test-files/solr/collection1/conf/schema.xml
index 31fd9e5..e0a96cc 100644
--- a/solr/core/src/test-files/solr/collection1/conf/schema.xml
+++ b/solr/core/src/test-files/solr/collection1/conf/schema.xml
@@ -651,6 +651,8 @@
   <!-- EnumType -->
   <field name="severity" type="severityType" docValues="true" indexed="true" stored="true" multiValued="false"/>
 
+  <field name="max_chars" type="string" indexed="false" stored="true"/>
+
 
   <!-- Dynamic field definitions.  If a field name is not found, dynamicFields
        will be used if the name matches any of the patterns.
@@ -850,6 +852,8 @@
   <copyField source="*_dynamic" dest="dynamic_*"/>
   <copyField source="*_path" dest="*_ancestor"/>
 
+  <copyField source="title" dest="max_chars" maxChars="10"/>
+
   <!-- example of a custom similarity -->
   <similarity class="solr.CustomSimilarityFactory">
     <str name="echo">I am your default sim</str>
diff --git a/solr/core/src/test/org/apache/solr/update/DocumentBuilderTest.java b/solr/core/src/test/org/apache/solr/update/DocumentBuilderTest.java
index bf819a0..1b0794b 100644
--- a/solr/core/src/test/org/apache/solr/update/DocumentBuilderTest.java
+++ b/solr/core/src/test/org/apache/solr/update/DocumentBuilderTest.java
@@ -30,6 +30,7 @@ import org.apache.solr.common.SolrDocument;
 import org.apache.solr.common.SolrException;
 import org.apache.solr.common.SolrInputDocument;
 import org.apache.solr.common.SolrInputField;
+import org.apache.solr.common.util.ByteArrayUtf8CharSequence;
 import org.apache.solr.core.SolrCore;
 import org.apache.solr.schema.FieldType;
 import org.junit.After;
@@ -274,4 +275,28 @@ public class DocumentBuilderTest extends SolrTestCaseJ4 {
     assertTrue(field.stringValue().startsWith("STORED V3|"));
   }
 
+  @Test
+  public void testCopyFieldMaxChars() {
+    SolrCore core = h.getCore();
+
+    String testValue = "this is more than 10 characters";
+    String truncatedValue = "this is mo";
+
+    //maxChars with a string value
+    SolrInputDocument doc = new SolrInputDocument();
+    doc.addField( "title", testValue);
+
+    Document out = DocumentBuilder.toDocument(doc, core.getLatestSchema());
+    assertEquals(testValue, out.get("title"));
+    assertEquals(truncatedValue, out.get("max_chars"));
+
+    //maxChars with a ByteArrayUtf8CharSequence
+    doc = new SolrInputDocument();
+    doc.addField( "title", new ByteArrayUtf8CharSequence(testValue));
+
+    out = DocumentBuilder.toDocument(doc, core.getLatestSchema());
+    assertEquals(testValue, out.get("title"));
+    assertEquals(truncatedValue, out.get("max_chars"));
+  }
+
 }


[lucene-solr] 02/02: SOLR-13699 - maxChars no longer working on CopyField with javabin

Posted by no...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

noble pushed a commit to branch branch_8x
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git

commit b7c9a9f4a1a72ac0003f9fa98582ad89e75f043f
Author: noble <no...@apache.org>
AuthorDate: Mon Aug 26 09:00:54 2019 +1000

    SOLR-13699 - maxChars no longer working on CopyField with javabin
---
 solr/CHANGES.txt | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 12591d0..4740ef1 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -122,6 +122,8 @@ Bug Fixes
 
 * SOLR-13704: Improve error message and change error code to 400 for client errors in ExpandComponent (Munendra S N)
 
+* SOLR-13699 - maxChars no longer working on CopyField with javabin (Chris Troullis via noble)
+
 Other Changes
 ----------------------