-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Add support for project_routing for _search and _async_search
#137566
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
Changes from 17 commits
3e94dc8
6ac9d8c
2d0f4c6
c09e00a
deb7b49
692c5a2
bad85a6
922cb53
97c184b
121d0f6
8b14d89
65a978c
301d2a0
a3dc375
0c7ee5d
888ed14
e0681d3
58f66d4
69155f8
2794828
7e8e30f
b1e06ef
52f5e32
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| pr: 137566 | ||
| summary: Add support for `project_routing` for `_search` and `_async_search` | ||
| area: CCS | ||
| type: enhancement | ||
| issues: [] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -620,7 +620,8 @@ public void onFailure(Exception e) { | |
| }), | ||
| forceConnectTimeoutSecs, | ||
| resolvesCrossProject, | ||
| rewritten.getResolvedIndexExpressions() | ||
| rewritten.getResolvedIndexExpressions(), | ||
| rewritten.getProjectRouting() | ||
| ); | ||
| } | ||
| } | ||
|
|
@@ -1065,7 +1066,8 @@ static void collectSearchShards( | |
| ActionListener<Map<String, SearchShardsResponse>> listener, | ||
| TimeValue forceConnectTimeoutSecs, | ||
| boolean resolvesCrossProject, | ||
| ResolvedIndexExpressions originResolvedIdxExpressions | ||
| ResolvedIndexExpressions originResolvedIdxExpressions, | ||
| String projectRouting | ||
| ) { | ||
| RemoteClusterService remoteClusterService = transportService.getRemoteClusterService(); | ||
| final CountDown responsesCountDown = new CountDown(remoteIndicesByCluster.size()); | ||
|
|
@@ -1104,7 +1106,7 @@ Map<String, SearchShardsResponse> createFinalResponse() { | |
| // We do not use the relaxed index options here when validating indices' existence. | ||
| ElasticsearchException validationEx = CrossProjectIndexResolutionValidator.validate( | ||
| originalIdxOpts, | ||
| null, | ||
| projectRouting, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @piergm - Can you help me understand why we want projectRouting to be passed into That doesn't seem right to me, but maybe I'm missing a use case here.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Consider these indices: Here's how it works, using Search as an example: the SAF uses project routing to resolve the projects that are in scope. Say, the routing is |
||
| originResolvedIdxExpressions, | ||
| resolvedIndexExpressions | ||
| ); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the Elastic License | ||
| * 2.0; you may not use this file except in compliance with the Elastic License | ||
| * 2.0. | ||
| */ | ||
|
|
||
| package org.elasticsearch.xpack.search; | ||
|
|
||
| import org.elasticsearch.client.Request; | ||
| import org.elasticsearch.client.ResponseException; | ||
| import org.elasticsearch.common.util.CollectionUtils; | ||
| import org.elasticsearch.plugins.Plugin; | ||
| import org.elasticsearch.test.ESIntegTestCase; | ||
| import org.hamcrest.Matchers; | ||
|
|
||
| import java.io.IOException; | ||
| import java.util.Collection; | ||
|
|
||
| public class ProjectRoutingDisallowedInNonCpsEnvIT extends ESIntegTestCase { | ||
| @Override | ||
| protected boolean addMockHttpTransport() { | ||
| return false; | ||
| } | ||
|
|
||
| @Override | ||
| protected Collection<Class<? extends Plugin>> nodePlugins() { | ||
| return CollectionUtils.appendToCopyNoNullElements(super.nodePlugins(), AsyncSearch.class); | ||
| } | ||
|
|
||
| public void testDisallowProjectRouting() throws IOException { | ||
| Request createAsyncRequest = new Request("POST", "/*,*:*/" + randomFrom("_async_search", "_search")); | ||
| createAsyncRequest.setJsonEntity(""" | ||
| { | ||
| "project_routing": "_alias:_origin" | ||
| } | ||
| """); | ||
|
|
||
| ResponseException err = expectThrows(ResponseException.class, () -> getRestClient().performRequest(createAsyncRequest)); | ||
| assertThat(err.toString(), Matchers.containsString("Unknown key for a VALUE_STRING in [project_routing]")); | ||
| } | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.