Skip to content

Conversation

@pawankartik-elastic
Copy link
Contributor

@pawankartik-elastic pawankartik-elastic commented Nov 14, 2025

For Cross Project Search, we:

  • Do not want any endpoints to set ccs_minimize_roundtrips. Should they attempt to do so, its value should be dropped, and,
  • _async_search should default ccs_minimize_roundtrips to true. All other searches, anyway, at present, default to true since they do not call setCcsMinimizeRoundtrips() and SearchRequest sets it to true upon its instantiation.

Currently, we do accept values for ccs_minimize_roundtrips for Serverless, even though there's no Cross Cluster Search functionality. However, it's ineffective since the search is effectively a "local" search (see TransportSearchAction#executeLocalSearch()) and the values get ignored. Since this parameter would have no effect in Serverless, moving forward, we plan on notifying the same to the user via a Kibana banner.

At some point in the future, instead of ignoring this parameter, we'll error out (only for Serverless).

  • Check if Kibana is capable of generating a warning by itself or if I need to explicitly use HeaderWarning#addWarning().

@elasticsearchmachine elasticsearchmachine added v9.3.0 serverless-linked Added by automation, don't add manually labels Nov 14, 2025
clusterSupportsFeature,
setSize,
searchUsageHolder,
Optional.empty()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previously, this overload passed in false for crossProjectEnabled. Now it passes in Optional.empty() to be compatible. Same theory, different syntax.

@pawankartik-elastic pawankartik-elastic added Team:Search Foundations Meta label for the Search Foundations team in Elasticsearch :Search Foundations/CCS labels Nov 14, 2025
@pawankartik-elastic pawankartik-elastic marked this pull request as ready for review November 14, 2025 16:39
@pawankartik-elastic pawankartik-elastic requested a review from a team as a code owner November 14, 2025 16:39
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-search-foundations (Team:Search Foundations)

@elasticsearchmachine
Copy link
Collaborator

Hi @pawankartik-elastic, I've created a changelog YAML for you.

Copy link
Contributor

@quux00 quux00 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a few comments for feedback.

public RestSearchTemplateAction(Predicate<NodeFeature> clusterSupportsFeature, Settings settings) {
this.clusterSupportsFeature = clusterSupportsFeature;
this.settings = settings;
this.crossProjectEnabled = settings != null && settings.getAsBoolean("serverless.cross_project.enabled", false);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we want to use the CrossProjectModeDecider for this, not hardcode the specific setting here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, yes! Thanks for pointing this one out.

size -> searchRequest.source().size(size)
size -> searchRequest.source().size(size),
null,
Optional.of(crossProjectEnabled)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It worries me that the only other RestAction (besides the obvious ones of RestSearchAction and the async RestSearchAction) you had to change was this one.

But there are other several Rest actions that converge on _search that are (or will be) also CPS enabled:

_msearch/template
_eql/search
_sql
_mvt
_<index>/_count
_cat/count

We should track down whether any of those allow setting ccs_minimize_roundtrips and if so, if additional code changes are needed.

Copy link
Contributor Author

@pawankartik-elastic pawankartik-elastic Nov 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The endpoints you've listed have their own dedicated parsing strategies that are lenient wrt the query parameters being passed, and there's some inconsistency between our public-facing docs and how the endpoints work. For example, for some of them, you can pass MRT, but it's not consumed. Here's why I only had to touch only a few Rest*Action-s:

  • Both _eql and _msearch/template accept MRT and have their own dedicated parser. I can accommodate these changes there.
  • _sql does not appear to accept MRT and has its own parser.
  • _mvt does not appear to accept MRT and has its own parser.
  • {index}/_count does not appear to accept MRT and has its own simple parser.
  • _cat/count does not appear to accept MRT and has its own simple parser.

Endpoints that aren't explicitly consuming MRT are defaulting to true.

Own parser = the parsing happens within the respective Rest*Action with info manually being extracted via RestRequest#param() and passed to the respective *Request-s.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome. Thanks. Excellent analysis. 🥇

@pawankartik-elastic pawankartik-elastic removed the request for review from a team November 17, 2025 10:00
@pawankartik-elastic pawankartik-elastic requested a review from a team as a code owner November 17, 2025 11:24
@pawankartik-elastic pawankartik-elastic removed the request for review from a team November 17, 2025 11:37
Copy link
Contributor

@quux00 quux00 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work. This looks good. Down to the last few comments/changes.

size -> searchRequest.source().size(size)
size -> searchRequest.source().size(size),
null,
Optional.of(crossProjectEnabled)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome. Thanks. Excellent analysis. 🥇

if (searchType != null) {
searchRequest.searchType(searchType);
}
// When crossProjectEnabled is true, ccsMinimizeRoundtrips is guaranteed to be true.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment seems out of place? Cross-project enabled part is handled down below, not here, so I'm not sure what this comment is getting at.

Also - be aware that a year from now this statement may no longer be true. We might go and change the default to be false for CPS everywhere if batched execution lives up to its promises, so comments like this will need to be tracked down and reversed/removed if/when that happens, so I would only add comments like this if there are really helpful to understand code flow.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a followup question on this: are we guaranteed that for serverless/CPS, we will keep same MRT mode for everywhere and not give a choice like we do for stateful CCS? The reason I'm asking is that right now telemetry explicitly does not track MRT state for CPS, but if we would in the future allow the user to choose then we may need to change that and start tracking it again like we do for CCS.

Copy link
Contributor Author

@pawankartik-elastic pawankartik-elastic Nov 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment is true but slightly misleading. MultiSearchRequest#readMultiLineFormat() is called from RestMultiSearchAction#parseMultiLineRequest(), and that's the method that passes down the ccsMinimizeRoundtrips you're seeing here — it refers to the MRT query parameter and is null when not specified. However, when provided an explicit value, we flip it to true anyway for CPS and pass it down here. That's what I meant by "ccsMinimizeRoundtrips is guaranteed to be true".

The misleading part: it only applies to CPS; should've mentioned this. I'll rewrite it in the next push.

Boolean ccsMinimizeRoundtrips,
boolean allowExplicitIndex
boolean allowExplicitIndex,
Optional<Boolean> crossProjectEnabled
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional suggestion: Add javadoc here what Optional.TRUE, Optional.FALSE and Optional.empty mean. That's not going to be obvious. Or if you feel like you have to document that 20 times, put a note here on where to see the javadoc for that?

if (crossProjectEnabled.orElse(false)) {
if (request.hasParam("ccs_minimize_roundtrips")) {
request.param("ccs_minimize_roundtrips");
HeaderWarning.addWarning(MRT_SET_IN_CPS_WARN);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would be the place to check that we don't set this warning more than once (if that's possible).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's only 1 place where we don't want to set this warning multiple times: when parsing multiline requests. I could use a simple boolean value to see if we've already fired a warning in the respective multiline request parser itself, rather than bloating up this method just to accommodate one scenario. Wdyt?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does that one place (multiline requests) use this method?

One option here is to add a new method to HeaderWarning: HeaderWarning.addWarningIfUnique(), but if that would take a while to build and test and you don't need it here, then consider this an optional suggestion.

We could also file a follow-on ticket to handle it later. It's not essential for CPS Tech Preview. (If you choose this path, let me know so I can create the GA scope ticket for it.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

>enhancement :Search Foundations/CCS serverless-linked Added by automation, don't add manually Team:Search Foundations Meta label for the Search Foundations team in Elasticsearch v9.3.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants