Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public class DocumentMapper {
private final MapperMetrics mapperMetrics;
private final IndexVersion indexVersion;
private final Logger logger;
private final String indexName;

/**
* Create a new {@link DocumentMapper} that holds empty mappings.
Expand Down Expand Up @@ -67,16 +68,17 @@ public static DocumentMapper createEmpty(MapperService mapperService) {
this.mapperMetrics = mapperMetrics;
this.indexVersion = version;
this.logger = Loggers.getLogger(getClass(), indexName);
this.indexName = indexName;

assert mapping.toCompressedXContent().equals(source) || isSyntheticSourceMalformed(source, version)
: "provided source [" + source + "] differs from mapping [" + mapping.toCompressedXContent() + "]";
}

private void maybeLog(Exception ex) {
if (logger.isDebugEnabled()) {
logger.debug("Error while parsing document: " + ex.getMessage(), ex);
logger.debug("Error while parsing document for index [" + indexName + "]: " + ex.getMessage(), ex);
} else if (IntervalThrottler.DOCUMENT_PARSING_FAILURE.accept()) {
logger.error("Error while parsing document: " + ex.getMessage(), ex);
logger.info("Error while parsing document for index [" + indexName + "]: " + ex.getMessage(), ex);
}
}

Expand Down