diff --git a/src/main/java/org/elasticsearch/index/get/ShardGetService.java b/src/main/java/org/elasticsearch/index/get/ShardGetService.java index ad3953d89cf..3d40fd8a3af 100644 --- a/src/main/java/org/elasticsearch/index/get/ShardGetService.java +++ b/src/main/java/org/elasticsearch/index/get/ShardGetService.java @@ -167,7 +167,7 @@ public class ShardGetService extends AbstractIndexShardComponent { } if (value == null) { if (field.isBinary()) { - value = field.getBinaryValue(); + value = new BytesArray(field.getBinaryValue(), field.getBinaryOffset(), field.getBinaryLength()); } else { value = field.stringValue(); } diff --git a/src/main/java/org/elasticsearch/search/fetch/FetchPhase.java b/src/main/java/org/elasticsearch/search/fetch/FetchPhase.java index 2cfa36d673d..bae3fff0a37 100644 --- a/src/main/java/org/elasticsearch/search/fetch/FetchPhase.java +++ b/src/main/java/org/elasticsearch/search/fetch/FetchPhase.java @@ -197,7 +197,7 @@ public class FetchPhase implements SearchPhase { } if (value == null) { if (field.isBinary()) { - value = field.getBinaryValue(); + value = new BytesArray(field.getBinaryValue(), field.getBinaryOffset(), field.getBinaryLength()); } else { value = field.stringValue(); }