-
Notifications
You must be signed in to change notification settings - Fork 25.5k
Integrate with the new resolve_cross_project IndicesOptions #136463
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
Merged
elasticsearchmachine
merged 6 commits into
elastic:main
from
ywangd:ES-13173-integrate-cps-indices-option
Oct 14, 2025
+102
−11
Merged
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
b815ae5
Integrate with the new resolve_cross_project IndicesOptions
ywangd b592810
license fix
ywangd d85edf3
unused log
ywangd 7d80fb1
Merge branch 'main' into ES-13173-integrate-cps-indices-option
elasticmachine a6aca9a
Merge remote-tracking branch 'origin/main' into ES-13173-integrate-cp…
ywangd b31eb10
Merge remote-tracking branch 'origin/main' into ES-13173-integrate-cp…
ywangd File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
...rc/test/java/org/elasticsearch/rest/action/admin/indices/RestResolveIndexActionTests.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* | ||
* 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", the "GNU Affero General Public License v3.0 only", and the "Server Side | ||
* Public License v 1"; you may not use this file except in compliance with, at | ||
* your election, the "Elastic License 2.0", the "GNU Affero General Public | ||
* License v3.0 only", or the "Server Side Public License, v 1". | ||
*/ | ||
package org.elasticsearch.rest.action.admin.indices; | ||
|
||
import org.elasticsearch.action.ActionListener; | ||
import org.elasticsearch.action.ActionRequest; | ||
import org.elasticsearch.action.ActionResponse; | ||
import org.elasticsearch.action.ActionType; | ||
import org.elasticsearch.action.admin.indices.resolve.ResolveIndexAction; | ||
import org.elasticsearch.client.internal.node.NodeClient; | ||
import org.elasticsearch.cluster.project.TestProjectResolvers; | ||
import org.elasticsearch.common.settings.Settings; | ||
import org.elasticsearch.rest.RestRequest; | ||
import org.elasticsearch.test.ESTestCase; | ||
import org.elasticsearch.test.rest.FakeRestChannel; | ||
import org.elasticsearch.test.rest.FakeRestRequest; | ||
import org.elasticsearch.threadpool.ThreadPool; | ||
|
||
import java.util.List; | ||
|
||
import static org.hamcrest.Matchers.equalTo; | ||
import static org.mockito.Mockito.mock; | ||
|
||
public class RestResolveIndexActionTests extends ESTestCase { | ||
|
||
public void testAddResolveCrossProjectBasedOnSettingValue() throws Exception { | ||
final boolean cpsEnabled = randomBoolean(); | ||
final Settings settings = Settings.builder().put("serverless.cross_project.enabled", cpsEnabled).build(); | ||
final var action = new RestResolveIndexAction(settings); | ||
final var request = new FakeRestRequest.Builder(xContentRegistry()).withMethod(RestRequest.Method.GET) | ||
.withPath("/_resolve/index/foo") | ||
.build(); | ||
|
||
final NodeClient nodeClient = new NodeClient(settings, mock(ThreadPool.class), TestProjectResolvers.DEFAULT_PROJECT_ONLY) { | ||
@SuppressWarnings("unchecked") | ||
@Override | ||
public <Request extends ActionRequest, Response extends ActionResponse> void doExecute( | ||
ActionType<Response> action, | ||
Request request, | ||
ActionListener<Response> listener | ||
) { | ||
final var resolveIndexRequest = asInstanceOf(ResolveIndexAction.Request.class, request); | ||
assertThat(resolveIndexRequest.indicesOptions().resolveCrossProjectIndexExpression(), equalTo(cpsEnabled)); | ||
listener.onResponse((Response) new ResolveIndexAction.Response(List.of(), List.of(), List.of())); | ||
} | ||
}; | ||
|
||
final var restChannel = new FakeRestChannel(request, true, 1); | ||
action.handleRequest(request, restChannel, nodeClient); | ||
assertThat(restChannel.responses().get(), equalTo(1)); | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just realised this:
parseSearchRequest()
can be called in 3 different scenarios:Therefore, simply setting this param to
false
will not help us accurately distinguish between the 2nd and the 3rd options. There are other areas in Elasticsearch where we need to represent such scenarios, and we resorted to using anOptional<Boolean>
. IIUC, we're using it forskip_unavailable
too (seeRemoteClusterService
). I actually have a PR where we modified this method to do the same: #135614 (reverted and is pending Breaking Change approval due to some other reasons). Can you accommodate those changes here?Wdyt @piergm?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall I'd prefer if you could make the necessary change with a follow-up. I updated it here because otherwise the serverless IT breaks without it. The search team is more qualified for further refinements. Does that work for you?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair enough! Proceed.