private DocumentReference createDocumentReference(Field field) {
        if (!isAttribute(field)) {
            throw new IllegalArgumentException(
                    String.format(
                            "The field '%s' is an invalid document reference. The field must be an attribute.",
                            field.getName()));
        }
        NewDocumentReferenceDataType reference = (NewDocumentReferenceDataType) field.getDataType();
        String targetDocumentName = getTargetDocumentName(reference);
        Schema schema = schemaMapping.get(targetDocumentName);
        if (schema == null) {
            throw new IllegalArgumentException(
                    String.format("Invalid document reference '%s': " +
                                  "Could not find document type '%s'", field.getName(), targetDocumentName));
        }
        return new DocumentReference(field, schema);
    }
Resolves all document references in the search definitions

Iterates through all document fields having a {@link NewDocumentReferenceDataType} and uses {@link NewDocumentReferenceDataType#getTargetTypeName()}
to determine the referenced document. This information is aggregated into a {@link DocumentReferences} object.

@author bjorncs
config-model/src/main/java/com/yahoo/schema/DocumentReferenceResolver.java