You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@solr.apache.org by GitBox <gi...@apache.org> on 2022/08/31 17:35:04 UTC

[GitHub] [solr] dsmiley commented on a diff in pull request #990: SOLR-16362: Logs: Truncate field values in logs if a doc fails to index

dsmiley commented on code in PR #990:
URL: https://github.com/apache/solr/pull/990#discussion_r959850094


##########
solr/core/src/java/org/apache/solr/update/DocumentBuilder.java:
##########
@@ -161,14 +162,21 @@ public static Document toDocument(
           && !sfield.multiValued()
           && field.getValueCount() > 1
           && !(sfield.getType() instanceof DenseVectorField)) {
+
+        // Ensure we do not flood the logs with extremely long values
+        String fieldValue = field.getValue().toString();
+        if (fieldValue.length() > MAX_VALUES_AS_STRING_LENGTH) {
+          fieldValue = fieldValue.substring(0, MAX_VALUES_AS_STRING_LENGTH - 4) + "...]";

Review Comment:
   Okay; that fieldValue is guaranteed to already end in that bracket is not obvious. Adding a simple `assert fieldValue.endsWith(']');` before truncating would be simple enough to clarify.  



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org