Skip to content
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -942,7 +942,7 @@ public void initRestHandlers(Supplier<DiscoveryNodes> nodesInCluster, Predicate<
registerHandler.accept(new RestBulkAction(settings, clusterSettings, bulkService));
registerHandler.accept(new RestUpdateAction());

registerHandler.accept(new RestSearchAction(restController.getSearchUsageHolder(), clusterSupportsFeature));
registerHandler.accept(new RestSearchAction(restController.getSearchUsageHolder(), clusterSupportsFeature, settings));
registerHandler.accept(new RestSearchScrollAction());
registerHandler.accept(new RestClearScrollAction());
registerHandler.accept(new RestOpenPointInTimeAction());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.elasticsearch.action.support.IndicesOptions;
import org.elasticsearch.client.internal.node.NodeClient;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.core.Booleans;
import org.elasticsearch.core.Nullable;
import org.elasticsearch.features.NodeFeature;
Expand Down Expand Up @@ -66,10 +67,16 @@ public class RestSearchAction extends BaseRestHandler {

private final SearchUsageHolder searchUsageHolder;
private final Predicate<NodeFeature> clusterSupportsFeature;
private final Settings settings;

public RestSearchAction(SearchUsageHolder searchUsageHolder, Predicate<NodeFeature> clusterSupportsFeature) {
this(searchUsageHolder, clusterSupportsFeature, null);
}

public RestSearchAction(SearchUsageHolder searchUsageHolder, Predicate<NodeFeature> clusterSupportsFeature, Settings settings) {
this.searchUsageHolder = searchUsageHolder;
this.clusterSupportsFeature = clusterSupportsFeature;
this.settings = settings;
}

@Override
Expand Down Expand Up @@ -101,6 +108,12 @@ public RestChannelConsumer prepareRequest(final RestRequest request, final NodeC
// access the BwC param, but just drop it
// this might be set by old clients
request.param("min_compatible_shard_node");

if (settings != null && settings.getAsBoolean("serverless.cross_project.enabled", false)) {
// accept but drop project_routing param until fully supported
request.param("project_routing");
}

/*
* We have to pull out the call to `source().size(size)` because
* _update_by_query and _delete_by_query uses this same parsing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public List<RestHandler> getRestHandlers(
Predicate<NodeFeature> clusterSupportsFeature
) {
return Arrays.asList(
new RestSubmitAsyncSearchAction(restController.getSearchUsageHolder(), clusterSupportsFeature),
new RestSubmitAsyncSearchAction(restController.getSearchUsageHolder(), clusterSupportsFeature, settings),
new RestGetAsyncSearchAction(),
new RestGetAsyncStatusAction(),
new RestDeleteAsyncSearchAction()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
package org.elasticsearch.xpack.search;

import org.elasticsearch.client.internal.node.NodeClient;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.features.NodeFeature;
import org.elasticsearch.rest.BaseRestHandler;
import org.elasticsearch.rest.RestRequest;
Expand Down Expand Up @@ -37,10 +38,20 @@ public final class RestSubmitAsyncSearchAction extends BaseRestHandler {

private final SearchUsageHolder searchUsageHolder;
private final Predicate<NodeFeature> clusterSupportsFeature;
private final Settings settings;

public RestSubmitAsyncSearchAction(SearchUsageHolder searchUsageHolder, Predicate<NodeFeature> clusterSupportsFeature) {
this(searchUsageHolder, clusterSupportsFeature, null);
}

public RestSubmitAsyncSearchAction(
SearchUsageHolder searchUsageHolder,
Predicate<NodeFeature> clusterSupportsFeature,
Settings settings
) {
this.searchUsageHolder = searchUsageHolder;
this.clusterSupportsFeature = clusterSupportsFeature;
this.settings = settings;
}

@Override
Expand All @@ -59,6 +70,12 @@ protected RestChannelConsumer prepareRequest(RestRequest request, NodeClient cli
client.threadPool().getThreadContext().setErrorTraceTransportHeader(request);
}
SubmitAsyncSearchRequest submit = new SubmitAsyncSearchRequest();

if (settings != null && settings.getAsBoolean("serverless.cross_project.enabled", false)) {
// accept but drop project_routing param until fully supported
request.param("project_routing");
}

IntConsumer setSize = size -> submit.getSearchRequest().source().size(size);
// for simplicity, we share parsing with ordinary search. That means a couple of unsupported parameters, like scroll
// and pre_filter_shard_size get set to the search request although the REST spec don't list
Expand Down