solrServer.commit();
return exampleId;
} catch (Exception e) {
String msg = String.format("Error deleting example with id '%s' on Solr Core '%s'",
exampleId, solrCoreId);
throw new TrainingSetException(msg, e);
}
}
if (exampleId == null || exampleId.isEmpty()) {
exampleId = UUID.randomUUID().toString();
}
SolrInputDocument doc = new SolrInputDocument();
doc.addField(exampleIdField, exampleId);
doc.addField(exampleTextField, text);
if (topics != null) {
doc.addField(topicUrisField, topics);
}
doc.addField(modificationDateField, UTCTimeStamper.nowUtcDate());
SolrServer server = getActiveSolrServer();
try {
server.add(doc);
server.commit();
} catch (Exception e) {
String msg = String.format("Could not register example '%s' with topics: ['%s']", exampleId,
StringUtils.join(topics, "', '"));
throw new TrainingSetException(msg, e);
}
return exampleId;
}