diff --git a/server/src/main/java/org/elasticsearch/search/SearchHit.java b/server/src/main/java/org/elasticsearch/search/SearchHit.java index 37de200dbba..2c56c713bb8 100644 --- a/server/src/main/java/org/elasticsearch/search/SearchHit.java +++ b/server/src/main/java/org/elasticsearch/search/SearchHit.java @@ -906,7 +906,7 @@ public final class SearchHit implements Writeable, ToXContentObject, Iterable { if (randomBoolean()) { nestedIdentity = NestedIdentityTests.createTestItem(randomIntBetween(0, 2)); } - Map fields = new HashMap<>(); - if (randomBoolean()) { - fields = GetResultTests.randomDocumentFields(xContentType).v2(); + Map fields = null; + if (frequently()) { + fields = new HashMap<>(); + if (randomBoolean()) { + fields = GetResultTests.randomDocumentFields(xContentType).v2(); + } } SearchHit hit = new SearchHit(internalId, uid, type, nestedIdentity, fields); if (frequently()) {