Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove legacy validation of search source in data nodes #113081

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 0 additions & 46 deletions server/src/main/java/org/elasticsearch/search/SearchService.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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
Expand Down