diff --git a/contrib/dataimporthandler/CHANGES.txt b/contrib/dataimporthandler/CHANGES.txt index e489f445c53..aa5de285566 100644 --- a/contrib/dataimporthandler/CHANGES.txt +++ b/contrib/dataimporthandler/CHANGES.txt @@ -31,7 +31,8 @@ Optimizations Bug Fixes ---------------------- - +* SOLR-1638: Fixed NullPointerException during import if uniqueKey is not specified + in schema (Akshay Ukey via shalin) Other Changes diff --git a/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/DataImporter.java b/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/DataImporter.java index 7d0c8dc2ff2..bd56e678653 100644 --- a/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/DataImporter.java +++ b/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/DataImporter.java @@ -149,8 +149,12 @@ public class DataImporter { } private void identifyPk(DataConfig.Entity entity) { - String schemaPk = schema.getUniqueKeyField().getName(); - //if no fields are mentioned . solr uniqeKey is same as dih 'pk' + SchemaField uniqueKey = schema.getUniqueKeyField(); + String schemaPk = ""; + if (uniqueKey != null) + schemaPk = uniqueKey.getName(); + else return; + //if no fields are mentioned . solr uniqueKey is same as dih 'pk' entity.pkMappingFromSchema = schemaPk; for (DataConfig.Field field : entity.fields) { if(field.getName().equals(schemaPk)) {