Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr open-source search software

Adding the document id to error message when you send multiple values for a single valued field.

Ryan McKinleye9c5d47cf37d
diff --git a/src/java/org/apache/solr/update/DocumentBuilder.java b/src/java/org/apache/solr/update/DocumentBuilder.java
index 435c7697803..1369ee78978 100644
--- a/src/java/org/apache/solr/update/DocumentBuilder.java
+++ b/src/java/org/apache/solr/update/DocumentBuilder.java
@@ -179,8 +179,13 @@ public class DocumentBuilder {
// Make sure it has the correct number
if( sfield!=null && !sfield.multiValued() && field.getValueCount() > 1 ) {
+ String id = "";
+ SchemaField sf = schema.getUniqueKeyField();
+ if( sf != null ) {
+ id = "["+doc.getFieldValue( sf.getName() )+"] ";
+ }
throw new SolrException( SolrException.ErrorCode.BAD_REQUEST,
- "ERROR: multiple values encountered for non multiValued field " +
+ "ERROR: "+id+"multiple values encountered for non multiValued field " +
sfield.getName() + ": " +field.getValue() );
}