// iterate on the annotations
if (includeAnnotations) {
Iterator<Annotation> iterator = doc.getAnnotations().iterator();
while (iterator.hasNext()) {
Annotation current = iterator.next();
// check whether it belongs to a type we'd like to send to SOLR
Map<String, String> featureField = fieldMapping.get(current
.getType());
// special case of all annotations
if (featureField == null && !includeAllAnnotations) {
continue;
}
if (!includeAllAnnotations) {
// iterate on the expected features
for (String targetFeature : featureField.keySet()) {
String SOLRFieldName = featureField.get(targetFeature);
String value = null;
// special case for covering text
if ("*".equals(targetFeature)) {
value = doc.getText().substring(
(int) current.getStart(),
(int) current.getEnd());
}
// get the value for the feature
else {
value = current.getFeatures().get(targetFeature);
}
LOG.debug("Adding field : " + SOLRFieldName + "\t"
+ value);
// skip if no value has been found
if (value != null)
inputDoc.addField(SOLRFieldName, value);
}
} else {
for (Entry<String, String> e : current.getFeatures()
.entrySet()) {
inputDoc.addField(annotationPrefix + current.getType()
+ "." + e.getKey(), e.getValue());
}
}
}
}