diff --git a/server/src/main/java/org/elasticsearch/search/SearchService.java b/server/src/main/java/org/elasticsearch/search/SearchService.java index b9770382c0484..a0b91261236b0 100644 --- a/server/src/main/java/org/elasticsearch/search/SearchService.java +++ b/server/src/main/java/org/elasticsearch/search/SearchService.java @@ -23,7 +23,6 @@ import org.elasticsearch.action.ResolvedIndices; import org.elasticsearch.action.search.CanMatchNodeRequest; import org.elasticsearch.action.search.CanMatchNodeResponse; -import org.elasticsearch.action.search.SearchRequest; import org.elasticsearch.action.search.SearchShardTask; import org.elasticsearch.action.search.SearchType; import org.elasticsearch.action.support.TransportActions; @@ -51,7 +50,6 @@ import org.elasticsearch.core.Releasable; import org.elasticsearch.core.Releasables; import org.elasticsearch.core.TimeValue; -import org.elasticsearch.core.UpdateForV9; import org.elasticsearch.index.Index; import org.elasticsearch.index.IndexNotFoundException; import org.elasticsearch.index.IndexService; @@ -1257,7 +1255,6 @@ private void parseSource(DefaultSearchContext context, SearchSourceBuilder sourc if (source == null) { return; } - validateSearchSource(source, context.scrollContext() != null); SearchShardTarget shardTarget = context.shardTarget(); SearchExecutionContext searchExecutionContext = context.getSearchExecutionContext(); context.from(source.from()); @@ -1453,49 +1450,6 @@ private void parseSource(DefaultSearchContext context, SearchSourceBuilder sourc } } - /** - * Validates the incoming search request on the data node. These checks have been moved to the coordinating node. - * Validation is still performed on the data nodes to ensure that in a mixed cluster scenario, when the coordinating node is on an older - * version that does not yet perform validation, the shards make up for that. - * This method can be entirely removed in the next major version, when all nodes perform the validation when coordinating a search. - * - * @see SearchRequest#validate() - */ - @UpdateForV9 - private static void validateSearchSource(SearchSourceBuilder source, boolean hasScroll) { - if (source.trackTotalHitsUpTo() != null && source.trackTotalHitsUpTo() != SearchContext.TRACK_TOTAL_HITS_ACCURATE && hasScroll) { - throw new IllegalArgumentException("disabling [track_total_hits] is not allowed in a scroll context"); - } - if (CollectionUtils.isEmpty(source.searchAfter()) == false) { - if (hasScroll) { - throw new IllegalArgumentException("`search_after` cannot be used in a scroll context."); - } - if (source.from() > 0) { - throw new IllegalArgumentException("`from` parameter must be set to 0 when `search_after` is used."); - } - } - if (source.collapse() != null) { - if (hasScroll) { - throw new IllegalArgumentException("cannot use `collapse` in a scroll context"); - } - } - if (source.slice() != null) { - if (source.pointInTimeBuilder() == null && (hasScroll == false)) { - throw new IllegalArgumentException("[slice] can only be used with [scroll] or [point-in-time] requests"); - } - } - if (source.storedFields() != null) { - if (source.storedFields().fetchFields() == false) { - if (source.fetchSource() != null && source.fetchSource().fetchSource()) { - throw new IllegalArgumentException("[stored_fields] cannot be disabled if [_source] is requested"); - } - if (source.fetchFields() != null) { - throw new IllegalArgumentException("[stored_fields] cannot be disabled when using the [fields] option"); - } - } - } - } - /** * Shortcut ids to load, we load only "from" and up to "size". The phase controller * handles this as well since the result is always size * shards for Q_T_F