private static String extractRecordId(SolrInputDocument doc) {
return doc.getFieldValue(BlurConstants.RECORD_ID).toString();
}
private static RecordMutation createRecordMutation(SolrInputDocument doc, String id) {
RecordMutation recordMutation = new RecordMutation();
// TODO: what's solr default behavior?
recordMutation.setRecordMutationType(RecordMutationType.REPLACE_ENTIRE_RECORD);
Record record = new Record();
record.setFamily(findFamily(doc));
record.setRecordId(id);
for (String fieldName : doc.getFieldNames()) {
if (!fieldName.contains(".")) {
continue;
}
SolrInputField field = doc.getField(fieldName);
String rawColumnName = fieldName.substring(fieldName.indexOf(".") + 1, fieldName.length());
if (field.getValueCount() > 1) {
for (Object fieldVal : field.getValues()) {
record.addToColumns(new Column(rawColumnName, fieldVal.toString()));
}
} else {
record.addToColumns(new Column(rawColumnName, field.getFirstValue().toString()));
}
}
recordMutation.setRecord(record);
return recordMutation;
}