" entries for vtags %3$s", vtRecord.getId().toString(), entry.getKey(),
vtagSetToNameString(entry.getValue())));
}
} else {
for (SchemaId vtag : entry.getValue()) {
SolrDocumentBuilder solrDocumentBuilder = new SolrDocumentBuilder(repository, lilyIndexerConf.getRecordFilter(),
lilyIndexerConf.getSystemFields(), valueEvaluator, table.getTableName(), version,
getIndexId(table.getTableName(), vtRecord.getId(), vtag), vtag, entry.getKey());
lilyIndexerConf.getIndexFields().collectIndexUpdate(solrDocumentBuilder);
if (!lilyIndexerConf.getDynamicFields().isEmpty()) {
for (Map.Entry<SchemaId, Object> field : idRecord.getFieldsById().entrySet()) {
FieldType fieldType = repository.getTypeManager().getFieldTypeById(field.getKey());
for (DynamicIndexField dynField : lilyIndexerConf.getDynamicFields()) {
DynamicIndexField.DynamicIndexFieldMatch match = dynField.matches(fieldType);
if (match.match) {
String fieldName = evalName(dynField, match, fieldType);
List<String> values = valueEvaluator.format(table.getTableName(), vtRecord.getRecord(), fieldType, dynField.extractContext(),
dynField.getFormatter(), repository);
solrDocumentBuilder.addField(fieldName, values);
if (!dynField.getContinue()) {
// stop on first match, unless continue attribute is true
break;
}
}
}
}
}
if (solrDocumentBuilder.isEmptyDocument()) {
// No single field was added to the Solr document.
// In this case we do not add it to the index.
// Besides being somewhat logical, it should also be noted that if a record would not contain
// any (modified) fields that serve as input to indexFields, we would never have arrived here
// anyway. It is only because some fields potentially would resolve to a value (potentially:
// because with deref-expressions we are never sure) that we did.
// There can be a previous entry in the index which we should try to delete
solrUpdateWriter.deleteById(LilyResultToSolrMapper.getIndexId(table.getTableName(),
vtRecord.getId(), vtag));
//metrics.deletesById.inc();
if (log.isDebugEnabled()) {
log.debug(String.format("Record %1$s, vtag %2$s: no index fields produced output, " +
"removed from index if present", vtRecord.getId(), safeLoadTagName(vtag)));
}
processDependencies(table.getTableName(), idRecord, vtag, solrDocumentBuilder);
} else {
SolrInputDocument solrDoc = solrDocumentBuilder.build();
processDependencies(table.getTableName(), idRecord, vtag, solrDocumentBuilder);
solrUpdateWriter.add(solrDoc);
//log.debug("index response " + solrShardMgr.getSolrClient(record.getId()).add(solrDoc).toString());
//metrics.adds.inc();