From b2fa6b7a94846a3a267117405d249ef228ee6192 Mon Sep 17 00:00:00 2001 From: Shay Banon Date: Tue, 29 Nov 2011 09:39:46 +0200 Subject: [PATCH] When _source is disabled, don't return it in realtime get fetching the document from the transaction log, closes #1509. --- .../java/org/elasticsearch/index/get/ShardGetService.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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 {