lucene-solr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hoss...@apache.org
Subject svn commit: r911595 - in /lucene/solr/trunk/src/java/org/apache/solr/update: DocumentBuilder.java UpdateHandler.java
Date Thu, 18 Feb 2010 21:29:09 GMT
Author: hossman
Date: Thu Feb 18 21:29:08 2010
New Revision: 911595

URL: http://svn.apache.org/viewvc?rev=911595&view=rev
Log:
SOLR-1695: revert DocumentBuilder changes from r9112332 and r911228 and improve the existing
error messages in UpdateHandler.getIndexedId instead

Modified:
    lucene/solr/trunk/src/java/org/apache/solr/update/DocumentBuilder.java
    lucene/solr/trunk/src/java/org/apache/solr/update/UpdateHandler.java

Modified: lucene/solr/trunk/src/java/org/apache/solr/update/DocumentBuilder.java
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/java/org/apache/solr/update/DocumentBuilder.java?rev=911595&r1=911594&r2=911595&view=diff
==============================================================================
--- lucene/solr/trunk/src/java/org/apache/solr/update/DocumentBuilder.java (original)
+++ lucene/solr/trunk/src/java/org/apache/solr/update/DocumentBuilder.java Thu Feb 18 21:29:08
2010
@@ -17,7 +17,6 @@
 
 package org.apache.solr.update;
 
-import java.util.Collection;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.HashMap;
@@ -226,22 +225,6 @@
   { 
     Document out = new Document();
     out.setBoost( doc.getDocumentBoost() );
-
-    final SchemaField uniqueKeyField = schema.getUniqueKeyField();
-    if (null != uniqueKeyField) {
-      Collection<Object> keys = doc.getFieldValues(uniqueKeyField.getName());
-      if (null == keys || keys.isEmpty()) {
-        throw new SolrException(SolrException.ErrorCode.BAD_REQUEST,
-                                "Document missing a value for uniqueKey field: " +
-                                uniqueKeyField.getName());
-      }
-      if (1 < keys.size()) {
-        throw new SolrException
-          (SolrException.ErrorCode.BAD_REQUEST,
-           "Document contains multiple values for uniqueKey field: " +
-           uniqueKeyField.getName());
-      }
-    }
     
     // Load fields from SolrDocument to Document
     for( SolrInputField field : doc ) {
@@ -252,10 +235,11 @@
       
       // Make sure it has the correct number
       if( sfield!=null && !sfield.multiValued() && field.getValueCount()
> 1 ) {
-        String id = ( uniqueKeyField == null )
-          ? ""
-          : ("["+doc.getFieldValue( uniqueKeyField.getName() )+"] ");
-
+        String id = "";
+        SchemaField sf = schema.getUniqueKeyField();
+        if( sf != null ) {
+          id = "["+doc.getFieldValue( sf.getName() )+"] ";
+        }
         throw new SolrException( SolrException.ErrorCode.BAD_REQUEST,
             "ERROR: "+id+"multiple values encountered for non multiValued field " + 
               sfield.getName() + ": " +field.getValue() );

Modified: lucene/solr/trunk/src/java/org/apache/solr/update/UpdateHandler.java
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/java/org/apache/solr/update/UpdateHandler.java?rev=911595&r1=911594&r2=911595&view=diff
==============================================================================
--- lucene/solr/trunk/src/java/org/apache/solr/update/UpdateHandler.java (original)
+++ lucene/solr/trunk/src/java/org/apache/solr/update/UpdateHandler.java Thu Feb 18 21:29:08
2010
@@ -111,9 +111,9 @@
     // form have that transformation already performed and stored as the field value.
     Fieldable[] id = doc.getFieldables( idField.getName() );
     if (id == null || id.length < 1)
-      throw new SolrException( SolrException.ErrorCode.BAD_REQUEST,"Document is missing uniqueKey
field " + idField.getName());
+      throw new SolrException( SolrException.ErrorCode.BAD_REQUEST,"Document is missing mandatory
uniqueKey field: " + idField.getName());
     if( id.length > 1 )
-      throw new SolrException( SolrException.ErrorCode.BAD_REQUEST,"Document specifies multiple
unique ids! " + idField.getName());
+      throw new SolrException( SolrException.ErrorCode.BAD_REQUEST,"Document contains multiple
values for uniqueKey field: " + idField.getName());
 
     return idFieldType.storedToIndexed( id[0] );
   }



Mime
View raw message