Skip to content

Commit 7db7407

Browse files
authored
Allow project_routing param in _search and _async_sync under feature flag only (#134240)
Allowing a project_routing query param in _search and _async_search under a serverless feature flag unblocks work that Kibana needs to do. The param is read but thrown away, so that searches do not behave any differently for now. Later work will implement functionality around this parameter.
1 parent 66582a3 commit 7db7407

File tree

4 files changed

+32
-2
lines changed

4 files changed

+32
-2
lines changed

server/src/main/java/org/elasticsearch/action/ActionModule.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -942,7 +942,7 @@ public void initRestHandlers(Supplier<DiscoveryNodes> nodesInCluster, Predicate<
942942
registerHandler.accept(new RestBulkAction(settings, clusterSettings, bulkService));
943943
registerHandler.accept(new RestUpdateAction());
944944

945-
registerHandler.accept(new RestSearchAction(restController.getSearchUsageHolder(), clusterSupportsFeature));
945+
registerHandler.accept(new RestSearchAction(restController.getSearchUsageHolder(), clusterSupportsFeature, settings));
946946
registerHandler.accept(new RestSearchScrollAction());
947947
registerHandler.accept(new RestClearScrollAction());
948948
registerHandler.accept(new RestOpenPointInTimeAction());

server/src/main/java/org/elasticsearch/rest/action/search/RestSearchAction.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import org.elasticsearch.action.support.IndicesOptions;
1717
import org.elasticsearch.client.internal.node.NodeClient;
1818
import org.elasticsearch.common.Strings;
19+
import org.elasticsearch.common.settings.Settings;
1920
import org.elasticsearch.core.Booleans;
2021
import org.elasticsearch.core.Nullable;
2122
import org.elasticsearch.features.NodeFeature;
@@ -66,10 +67,16 @@ public class RestSearchAction extends BaseRestHandler {
6667

6768
private final SearchUsageHolder searchUsageHolder;
6869
private final Predicate<NodeFeature> clusterSupportsFeature;
70+
private final Settings settings;
6971

7072
public RestSearchAction(SearchUsageHolder searchUsageHolder, Predicate<NodeFeature> clusterSupportsFeature) {
73+
this(searchUsageHolder, clusterSupportsFeature, null);
74+
}
75+
76+
public RestSearchAction(SearchUsageHolder searchUsageHolder, Predicate<NodeFeature> clusterSupportsFeature, Settings settings) {
7177
this.searchUsageHolder = searchUsageHolder;
7278
this.clusterSupportsFeature = clusterSupportsFeature;
79+
this.settings = settings;
7380
}
7481

7582
@Override
@@ -101,6 +108,12 @@ public RestChannelConsumer prepareRequest(final RestRequest request, final NodeC
101108
// access the BwC param, but just drop it
102109
// this might be set by old clients
103110
request.param("min_compatible_shard_node");
111+
112+
if (settings != null && settings.getAsBoolean("serverless.cross_project.enabled", false)) {
113+
// accept but drop project_routing param until fully supported
114+
request.param("project_routing");
115+
}
116+
104117
/*
105118
* We have to pull out the call to `source().size(size)` because
106119
* _update_by_query and _delete_by_query uses this same parsing

x-pack/plugin/async-search/src/main/java/org/elasticsearch/xpack/search/AsyncSearch.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public List<RestHandler> getRestHandlers(
5555
Predicate<NodeFeature> clusterSupportsFeature
5656
) {
5757
return Arrays.asList(
58-
new RestSubmitAsyncSearchAction(restController.getSearchUsageHolder(), clusterSupportsFeature),
58+
new RestSubmitAsyncSearchAction(restController.getSearchUsageHolder(), clusterSupportsFeature, settings),
5959
new RestGetAsyncSearchAction(),
6060
new RestGetAsyncStatusAction(),
6161
new RestDeleteAsyncSearchAction()

x-pack/plugin/async-search/src/main/java/org/elasticsearch/xpack/search/RestSubmitAsyncSearchAction.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
package org.elasticsearch.xpack.search;
88

99
import org.elasticsearch.client.internal.node.NodeClient;
10+
import org.elasticsearch.common.settings.Settings;
1011
import org.elasticsearch.features.NodeFeature;
1112
import org.elasticsearch.rest.BaseRestHandler;
1213
import org.elasticsearch.rest.RestRequest;
@@ -37,10 +38,20 @@ public final class RestSubmitAsyncSearchAction extends BaseRestHandler {
3738

3839
private final SearchUsageHolder searchUsageHolder;
3940
private final Predicate<NodeFeature> clusterSupportsFeature;
41+
private final Settings settings;
4042

4143
public RestSubmitAsyncSearchAction(SearchUsageHolder searchUsageHolder, Predicate<NodeFeature> clusterSupportsFeature) {
44+
this(searchUsageHolder, clusterSupportsFeature, null);
45+
}
46+
47+
public RestSubmitAsyncSearchAction(
48+
SearchUsageHolder searchUsageHolder,
49+
Predicate<NodeFeature> clusterSupportsFeature,
50+
Settings settings
51+
) {
4252
this.searchUsageHolder = searchUsageHolder;
4353
this.clusterSupportsFeature = clusterSupportsFeature;
54+
this.settings = settings;
4455
}
4556

4657
@Override
@@ -59,6 +70,12 @@ protected RestChannelConsumer prepareRequest(RestRequest request, NodeClient cli
5970
client.threadPool().getThreadContext().setErrorTraceTransportHeader(request);
6071
}
6172
SubmitAsyncSearchRequest submit = new SubmitAsyncSearchRequest();
73+
74+
if (settings != null && settings.getAsBoolean("serverless.cross_project.enabled", false)) {
75+
// accept but drop project_routing param until fully supported
76+
request.param("project_routing");
77+
}
78+
6279
IntConsumer setSize = size -> submit.getSearchRequest().source().size(size);
6380
// for simplicity, we share parsing with ordinary search. That means a couple of unsupported parameters, like scroll
6481
// and pre_filter_shard_size get set to the search request although the REST spec don't list

0 commit comments

Comments
 (0)