diff --git a/server/src/main/java/org/elasticsearch/index/query/InnerHitBuilder.java b/server/src/main/java/org/elasticsearch/index/query/InnerHitBuilder.java index 81dbc4c2e0a69..44fac46fdb99d 100644 --- a/server/src/main/java/org/elasticsearch/index/query/InnerHitBuilder.java +++ b/server/src/main/java/org/elasticsearch/index/query/InnerHitBuilder.java @@ -424,7 +424,7 @@ public InnerHitBuilder addFetchField(String name) { * @param format an optional format string used when formatting values, for example a date format. */ public InnerHitBuilder addFetchField(String name, @Nullable String format) { - if (fetchFields == null) { + if (fetchFields == null || fetchFields.isEmpty()) { fetchFields = new ArrayList<>(); } fetchFields.add(new FieldAndFormat(name, format));