SOLR-1638 -- Fixed NullPointerException during import if uniqueKey is not specified in schema

git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@889115 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Shalin Shekhar Mangar 2009-12-10 07:01:58 +00:00
parent 8e5d7bbbd3
commit 6b71440883
2 changed files with 8 additions and 3 deletions

View File

@ -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

View File

@ -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)) {