Skip to content

Add CCS Remote Views Detection#143384

Merged
elasticsearchmachine merged 12 commits intoelastic:mainfrom
jfreden:views/add_ccs
Mar 13, 2026
Merged

Add CCS Remote Views Detection#143384
elasticsearchmachine merged 12 commits intoelastic:mainfrom
jfreden:views/add_ccs

Conversation

@jfreden
Copy link
Copy Markdown
Contributor

@jfreden jfreden commented Mar 2, 2026

This PR adds detection of ES|QL views on remote clusters during cross-cluster search (CCS) and rejects queries that reference them, since views on remote clusters are not yet supported.

The error will tell the user which cluster contained what views and how to fix the issue, for example the query:

FROM remote-cluster:logs-*

Where remote-cluster has a view logs-nginx the error message will be:

ES|QL does not support views in cross-cluster search. View [logs-nginx] was found on [remote-cluster]. To exclude, use [remote-cluster:-logs-nginx] in the index expression. 

Since this exception can be avoided by adding exclusions to the query, this exception will ignore skip unavailable to make sure that the remote views issue won't be silently ignored.

@jfreden jfreden changed the title Add CCS Views Support [WIP] Add CCS Views Support Mar 3, 2026
@jfreden jfreden force-pushed the views/add_ccs branch 6 times, most recently from 9bba074 to 8d8c19f Compare March 9, 2026 13:32
@jfreden jfreden changed the title [WIP] Add CCS Views Support Add CCS Remote Views Detection Mar 9, 2026
elasticsearchmachine pushed a commit that referenced this pull request Mar 11, 2026
There has been several discussions on this topic since I opened
#141050 and @idegtiarenko
also mentioned this in
#143561 (comment).


The issue is that both `resolveViews` and `resolveAliases` are in
`WildcardOptions` but are used when resolving both concrete index
pattern targets and wildcard targets. This PR moves `resolveViews` from
`IndicesOptions.WildcardOptions` into a new
`IndicesOptions.IndexAbstractionOptions` record to address this
confusing inconsistency. 

This is in preparation for sending `resolveViews` as a parameter to
field caps for remote view resolving where more work will be done to
serialize `resolveViews` and not having this in place would make for
confusing code. See #143384
for more information on the upcoming serialization of `resolveViews`. 

**_Note_**: `resolveAliases` is moved in a follow up PR since it's
decoupled from the resolveViews changes.
#143953

**_Note_**: `IndicesRequest.includeDataStreams()` is the same type of
flag as `resolveAliases` and `resolveViews`, it controls whether data
streams participate in index resolution. It's a candidate for
`IndexAbstractionOptions` but currently lives on `IndicesRequest` (not
`IndicesOptions`) and is threaded separately through
`IndexNameExpressionResolver.Context` as a constructor parameter. Moving
it would touch 60+ files and change the `IndicesRequest` interface.
Because of how big that change would be, I have not considered doing
that in this PR (or at all).
@jfreden jfreden force-pushed the views/add_ccs branch 3 times, most recently from 4f9bdd9 to b893fc7 Compare March 12, 2026 14:21
}

String clusterAlias() {
public String clusterAlias() {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Needed for creating a good error message.

package org.elasticsearch.xpack.esql.ccq;

import org.elasticsearch.test.cluster.ElasticsearchCluster;
import org.elasticsearch.test.cluster.FeatureFlag;
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added a test here to make sure this works end-to-end.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I guess the test you added was testRemoteViewFailsQuery?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes!

// During CCS, resolveViews is only set on a request from the originating cluster and is therefore only true on a remote cluster
if (request.indicesOptions().indexAbstractionOptions().resolveViews()) {
Set<String> localViews = getViews(request.indices(), request.indicesOptions(), request.getResolvedIndexExpressions());
if (localViews.isEmpty() == false) {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We will only pass this point if there are no views on the remote cluster, so it's safe to pass the request on to field caps.

Finding remote views will always result in failure so no need to add any special handling for views in field caps.

@jfreden jfreden marked this pull request as ready for review March 12, 2026 15:42
@jfreden jfreden added >enhancement :Security/Security Security issues without another label labels Mar 12, 2026
@elasticsearchmachine elasticsearchmachine added the Team:Security Meta label for security team label Mar 12, 2026
@elasticsearchmachine
Copy link
Copy Markdown
Collaborator

Hi @jfreden, I've created a changelog YAML for you.

@jfreden jfreden added :Analytics/ES|QL AKA ESQL and removed :Security/Security Security issues without another label Team:Security Meta label for security team labels Mar 12, 2026
@elasticsearchmachine elasticsearchmachine added the Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) label Mar 12, 2026
@elasticsearchmachine
Copy link
Copy Markdown
Collaborator

Pinging @elastic/es-analytical-engine (Team:Analytics)

@idegtiarenko idegtiarenko self-requested a review March 12, 2026 15:45
@idegtiarenko idegtiarenko self-requested a review March 13, 2026 10:41
@jfreden jfreden added the auto-merge-without-approval Automatically merge pull request when CI checks pass (NB doesn't wait for reviews!) label Mar 13, 2026
@jfreden jfreden removed the auto-merge-without-approval Automatically merge pull request when CI checks pass (NB doesn't wait for reviews!) label Mar 13, 2026
@jfreden jfreden added the auto-merge-without-approval Automatically merge pull request when CI checks pass (NB doesn't wait for reviews!) label Mar 13, 2026
@elasticsearchmachine elasticsearchmachine merged commit fce799d into elastic:main Mar 13, 2026
36 checks passed
@jfreden jfreden deleted the views/add_ccs branch March 13, 2026 14:50
szybia added a commit to szybia/elasticsearch that referenced this pull request Mar 13, 2026
…elocations

* upstream/main: (72 commits)
  [Test] Randomly disable sequence numbers in CcrTimeSeriesDataStreamsIT (elastic#143930)
  Fix AsyncSearchIndexServiceTests.testCircuitBreaker failure (elastic#144058)
  Refine GenerativeIT some more, this time with accounting for some added (elastic#144220)
  ESQL: Physical Planning on the Lookup Node (elastic#143707)
  Mute org.elasticsearch.xpack.esql.CsvIT test {csv-spec:approximation.Approximate stats by with zero variance} elastic#144240
  Trigger counter metrics in test for delta temporality measurements (elastic#144193)
  fix capabiltiy approximation_v3 (elastic#144230)
  [ci] Add PR pipeline for testing ipv6 and fix tests not working with ipv6 (elastic#140473)
  update (elastic#144095)
  Make from/to optional in TBUCKET when Kibana timestamp filter is present (elastic#144057)
  Extract reroute behavior from create-index request classes (elastic#144140)
  ESQL: Fix release build only failures (elastic#144122)
  ES|QL query approximation: move sample correction to data node (elastic#144005)
  Add indexing pressure tracking to OTLP endpoints (elastic#144009)
  Fix replica writes after _seq_no doc values are pruned (elastic#144180)
  allow tests to configure supportsLoadingConfig (elastic#144061)
  [ES|QL] Unmute testGiantTextFieldInSubqueryIntermediateResultsWithSort (elastic#144126)
  [ESQL][DOCS] Add CPS page (unpublished for moment) (elastic#144206)
  ESQL: Forbid "load" unmapped_fields for certain commands (elastic#144115)
  Add CCS Remote Views Detection (elastic#143384)
  ...
michalborek pushed a commit to michalborek/elasticsearch that referenced this pull request Mar 23, 2026
This PR adds detection of ES|QL views on remote clusters during
cross-cluster search (CCS) and rejects queries that reference them,
since views on remote clusters are not yet supported.

The error will tell the user which cluster contained what views and how
to fix the issue, for example the query:

```
FROM remote-cluster:logs-*
```

Where `remote-cluster` has a view `logs-nginx` the error message will
be:

```
ES|QL does not support views in cross-cluster search. View [logs-nginx] was found on [remote-cluster]. To exclude, use [remote-cluster:-logs-nginx] in the index expression.
```

Since this exception can be avoided by adding exclusions to the query,
this exception will ignore [skip
unavailable](https://www.elastic.co/docs/explore-analyze/cross-cluster-search#ccs-remote-cluster-setup)
to make sure that the remote views issue won't be silently ignored.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

:Analytics/ES|QL AKA ESQL auto-merge-without-approval Automatically merge pull request when CI checks pass (NB doesn't wait for reviews!) >enhancement Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) v9.4.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants