From d116b594c12cfddf0883e1d70822112173703d72 Mon Sep 17 00:00:00 2001 From: Stanislav Malyshev Date: Fri, 27 Jun 2025 22:16:37 -0600 Subject: [PATCH] Apply skip_un to more cases --- .../org/elasticsearch/xpack/esql/session/EsqlCCSUtils.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/session/EsqlCCSUtils.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/session/EsqlCCSUtils.java index 51cb9b35becb1..4289c92339513 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/session/EsqlCCSUtils.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/session/EsqlCCSUtils.java @@ -100,6 +100,7 @@ static boolean returnSuccessWithEmptyResult(EsqlExecutionInfo executionInfo, Exc return false; } + // On disconnect error, check whether all remotes are marked as skip_unavailable. if (e instanceof NoClustersToSearchException || ExceptionsHelper.isRemoteUnavailableException(e)) { for (String clusterAlias : executionInfo.clusterAliases()) { if (executionInfo.isSkipUnavailable(clusterAlias) == false @@ -109,6 +110,12 @@ static boolean returnSuccessWithEmptyResult(EsqlExecutionInfo executionInfo, Exc } return true; } + + // If all clusters are skippable remotes, then we can return an empty result. + if (executionInfo.clusterAliases().stream().allMatch(executionInfo::isSkipUnavailable)) { + return true; + } + return false; }