|  | @@ -9,7 +9,9 @@
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  package org.elasticsearch.index.mapper;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +import org.apache.logging.log4j.Logger;
 | 
	
		
			
				|  |  |  import org.elasticsearch.common.compress.CompressedXContent;
 | 
	
		
			
				|  |  | +import org.elasticsearch.common.logging.Loggers;
 | 
	
		
			
				|  |  |  import org.elasticsearch.features.NodeFeature;
 | 
	
		
			
				|  |  |  import org.elasticsearch.index.IndexSettings;
 | 
	
		
			
				|  |  |  import org.elasticsearch.index.IndexSortConfig;
 | 
	
	
		
			
				|  | @@ -25,6 +27,7 @@ public class DocumentMapper {
 | 
	
		
			
				|  |  |      private final DocumentParser documentParser;
 | 
	
		
			
				|  |  |      private final MapperMetrics mapperMetrics;
 | 
	
		
			
				|  |  |      private final IndexVersion indexVersion;
 | 
	
		
			
				|  |  | +    private final Logger logger;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      static final NodeFeature INDEX_SORTING_ON_NESTED = new NodeFeature("mapper.index_sorting_on_nested");
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -44,7 +47,8 @@ public class DocumentMapper {
 | 
	
		
			
				|  |  |              mapping,
 | 
	
		
			
				|  |  |              mapping.toCompressedXContent(),
 | 
	
		
			
				|  |  |              IndexVersion.current(),
 | 
	
		
			
				|  |  | -            mapperService.getMapperMetrics()
 | 
	
		
			
				|  |  | +            mapperService.getMapperMetrics(),
 | 
	
		
			
				|  |  | +            mapperService.index().getName()
 | 
	
		
			
				|  |  |          );
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -53,7 +57,8 @@ public class DocumentMapper {
 | 
	
		
			
				|  |  |          Mapping mapping,
 | 
	
		
			
				|  |  |          CompressedXContent source,
 | 
	
		
			
				|  |  |          IndexVersion version,
 | 
	
		
			
				|  |  | -        MapperMetrics mapperMetrics
 | 
	
		
			
				|  |  | +        MapperMetrics mapperMetrics,
 | 
	
		
			
				|  |  | +        String indexName
 | 
	
		
			
				|  |  |      ) {
 | 
	
		
			
				|  |  |          this.documentParser = documentParser;
 | 
	
		
			
				|  |  |          this.type = mapping.getRoot().fullPath();
 | 
	
	
		
			
				|  | @@ -61,11 +66,18 @@ public class DocumentMapper {
 | 
	
		
			
				|  |  |          this.mappingSource = source;
 | 
	
		
			
				|  |  |          this.mapperMetrics = mapperMetrics;
 | 
	
		
			
				|  |  |          this.indexVersion = version;
 | 
	
		
			
				|  |  | +        this.logger = Loggers.getLogger(getClass(), indexName);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          assert mapping.toCompressedXContent().equals(source) || isSyntheticSourceMalformed(source, version)
 | 
	
		
			
				|  |  |              : "provided source [" + source + "] differs from mapping [" + mapping.toCompressedXContent() + "]";
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +    private void maybeLogDebug(Exception ex) {
 | 
	
		
			
				|  |  | +        if (logger.isDebugEnabled()) {
 | 
	
		
			
				|  |  | +            logger.debug("Error while parsing document: " + ex.getMessage(), ex);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |      /**
 | 
	
		
			
				|  |  |       * Indexes built at v.8.7 were missing an explicit entry for synthetic_source.
 | 
	
		
			
				|  |  |       * This got restored in v.8.10 to avoid confusion. The change is only restricted to mapping printout, it has no
 | 
	
	
		
			
				|  | @@ -110,7 +122,12 @@ public class DocumentMapper {
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      public ParsedDocument parse(SourceToParse source) throws DocumentParsingException {
 | 
	
		
			
				|  |  | -        return documentParser.parseDocument(source, mappingLookup);
 | 
	
		
			
				|  |  | +        try {
 | 
	
		
			
				|  |  | +            return documentParser.parseDocument(source, mappingLookup);
 | 
	
		
			
				|  |  | +        } catch (Exception e) {
 | 
	
		
			
				|  |  | +            maybeLogDebug(e);
 | 
	
		
			
				|  |  | +            throw e;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      public void validate(IndexSettings settings, boolean checkLimits) {
 |