From e9c5d47cf37d6841bab2ef7f11e90af4a5e3d5ac Mon Sep 17 00:00:00 2001 From: Ryan McKinley Date: Tue, 9 Oct 2007 23:22:53 +0000 Subject: [PATCH] Adding the document id to error message when you send multiple values for a single valued field. git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@583320 13f79535-47bb-0310-9956-ffa450edef68 --- src/java/org/apache/solr/update/DocumentBuilder.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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() ); }