diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/get/ShardGetService.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/get/ShardGetService.java index eeacbe50d1a..b7fec0987e8 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/get/ShardGetService.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/get/ShardGetService.java @@ -306,7 +306,7 @@ public class ShardGetService extends AbstractIndexShardComponent { FieldMapper x = docMapper.mappers().smartNameFieldMapper(field); value = searchLookup.source().extractValue(field); if (x != null && value instanceof String) { - value = x.valueFromString((String)value); + value = x.valueFromString((String) value); } } } @@ -324,6 +324,11 @@ public class ShardGetService extends AbstractIndexShardComponent { } } + // if source is not enabled, don't return it even though we have it from the translog + if (sourceRequested && !docMapper.sourceMapper().enabled()) { + sourceRequested = false; + } + return new GetResult(shardId.index().name(), type, id, get.version(), get.exists(), sourceRequested ? source.source : null, fields); } } finally {