mirror of https://github.com/apache/lucene.git
SOLR-1695: revert DocumentBuilder changes from r9112332 and r911228 and improve the existing error messages in UpdateHandler.getIndexedId instead
git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@911595 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
d5f6ae6095
commit
85d5802400
|
@ -17,7 +17,6 @@
|
||||||
|
|
||||||
package org.apache.solr.update;
|
package org.apache.solr.update;
|
||||||
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
@ -227,22 +226,6 @@ public class DocumentBuilder {
|
||||||
Document out = new Document();
|
Document out = new Document();
|
||||||
out.setBoost( doc.getDocumentBoost() );
|
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
|
// Load fields from SolrDocument to Document
|
||||||
for( SolrInputField field : doc ) {
|
for( SolrInputField field : doc ) {
|
||||||
String name = field.getName();
|
String name = field.getName();
|
||||||
|
@ -252,10 +235,11 @@ public class DocumentBuilder {
|
||||||
|
|
||||||
// Make sure it has the correct number
|
// Make sure it has the correct number
|
||||||
if( sfield!=null && !sfield.multiValued() && field.getValueCount() > 1 ) {
|
if( sfield!=null && !sfield.multiValued() && field.getValueCount() > 1 ) {
|
||||||
String id = ( uniqueKeyField == null )
|
String id = "";
|
||||||
? ""
|
SchemaField sf = schema.getUniqueKeyField();
|
||||||
: ("["+doc.getFieldValue( uniqueKeyField.getName() )+"] ");
|
if( sf != null ) {
|
||||||
|
id = "["+doc.getFieldValue( sf.getName() )+"] ";
|
||||||
|
}
|
||||||
throw new SolrException( SolrException.ErrorCode.BAD_REQUEST,
|
throw new SolrException( SolrException.ErrorCode.BAD_REQUEST,
|
||||||
"ERROR: "+id+"multiple values encountered for non multiValued field " +
|
"ERROR: "+id+"multiple values encountered for non multiValued field " +
|
||||||
sfield.getName() + ": " +field.getValue() );
|
sfield.getName() + ": " +field.getValue() );
|
||||||
|
|
|
@ -111,9 +111,9 @@ public abstract class UpdateHandler implements SolrInfoMBean {
|
||||||
// form have that transformation already performed and stored as the field value.
|
// form have that transformation already performed and stored as the field value.
|
||||||
Fieldable[] id = doc.getFieldables( idField.getName() );
|
Fieldable[] id = doc.getFieldables( idField.getName() );
|
||||||
if (id == null || id.length < 1)
|
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 )
|
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] );
|
return idFieldType.storedToIndexed( id[0] );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue