diff --git a/server/src/main/java/org/elasticsearch/search/builder/SearchSourceBuilder.java b/server/src/main/java/org/elasticsearch/search/builder/SearchSourceBuilder.java index 4186468b69651..333f7931c9148 100644 --- a/server/src/main/java/org/elasticsearch/search/builder/SearchSourceBuilder.java +++ b/server/src/main/java/org/elasticsearch/search/builder/SearchSourceBuilder.java @@ -2273,13 +2273,12 @@ public ActionRequestValidationException validate(ActionRequestValidationExceptio validationException ); } - if (fetchSource() != null) { + if (fetchFields() != null) { validationException = addValidationError( "[stored_fields] cannot be disabled when using the [fields] option", validationException ); } - } } if (subSearches().size() >= 2 && rankBuilder() == null) { @@ -2300,7 +2299,7 @@ public ActionRequestValidationException validate(ActionRequestValidationExceptio + rankBuilder().rankWindowSize() + "]" + " be greater than or equal to [size: " - + size() + + s + "]", validationException );