From 364668dba9753abb7a1360dbb9c8e035c7eab491 Mon Sep 17 00:00:00 2001 From: Michael Peterson Date: Fri, 4 Aug 2023 16:15:10 -0400 Subject: [PATCH] PR feedback --- .../search-across-clusters.asciidoc | 16 ---------- .../action/search/TransportSearchAction.java | 29 ------------------- 2 files changed, 45 deletions(-) diff --git a/docs/reference/search/search-your-data/search-across-clusters.asciidoc b/docs/reference/search/search-your-data/search-across-clusters.asciidoc index 97f8cf515eccc..d4a37ae03dd9f 100644 --- a/docs/reference/search/search-your-data/search-across-clusters.asciidoc +++ b/docs/reference/search/search-your-data/search-across-clusters.asciidoc @@ -431,22 +431,6 @@ The API returns the following response: -------------------------------------------------- // TEST[skip: terminated_early is absent from final results so is hard to reproduce here] -x // TESTRESPONSE[s/FklQYndoTDJ2VEFlMEVBTzFJMGhJVFEaLVlKYndBWWZSMUdicUc4WVlEaFl4ZzoxNTU=/$body.id/] -x // TESTRESPONSE[s/"is_partial": true/"is_partial": $body.is_partial/] -x // TESTRESPONSE[s/"is_running": true/"is_running": $body.is_running/] -x // TESTRESPONSE[s/1685563581380/$body.start_time_in_millis/] -x // TESTRESPONSE[s/1685995581380/$body.expiration_time_in_millis/] -x // TESTRESPONSE[s/"response"/"completion_time_in_millis": $body.completion_time_in_millis,\n "response"/] -x // TESTRESPONSE[s/"num_reduce_phases": 0/"num_reduce_phases": "$body.response.num_reduce_phases"/] -x // TESTRESPONSE[s/"took": 1020/"took": "$body.response.took"/] -x // TESTRESPONSE[s/"total": 8/"total": $body.response._shards.total/] -x // TESTRESPONSE[s/"successful": 0/"successful": $body.response._shards.successful/] -x // TESTRESPONSE[s/"successful" : 0/"successful": $body.response._clusters.successful/] -x // TESTRESPONSE[s/"value": 0/"value": "$body.response.hits.total.value"/] -x // TESTRESPONSE[s/"max_score": null/"max_score": "$body.response.hits.max_score"/] -x // TESTRESPONSE[s/"hits": \[\]/"hits": $body.response.hits.hits/] - - <1> The async search id. <2> When `ccs_minimize_roundtrips` = `true` and searches on the remote clusters are still running, this section indicates the number of shards in scope for the diff --git a/server/src/main/java/org/elasticsearch/action/search/TransportSearchAction.java b/server/src/main/java/org/elasticsearch/action/search/TransportSearchAction.java index 42c6ae1525541..7249f6f843979 100644 --- a/server/src/main/java/org/elasticsearch/action/search/TransportSearchAction.java +++ b/server/src/main/java/org/elasticsearch/action/search/TransportSearchAction.java @@ -76,10 +76,7 @@ import org.elasticsearch.transport.TransportRequestOptions; import org.elasticsearch.transport.TransportResponseHandler; import org.elasticsearch.transport.TransportService; -import org.elasticsearch.xcontent.ToXContent; -import org.elasticsearch.xcontent.XContentFactory; -import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -539,7 +536,6 @@ public void onResponse(SearchResponse searchResponse) { @Override public void onFailure(Exception e) { ShardSearchFailure failure = new ShardSearchFailure(e); - logCCSError(failure, clusterAlias, skipUnavailable); ccsClusterInfoUpdate(failure, clusters.getCluster(clusterAlias), skipUnavailable); if (skipUnavailable) { listener.onResponse(SearchResponse.empty(timeProvider::buildTookInMillis, clusters)); @@ -1411,7 +1407,6 @@ public final void onResponse(Response response) { @Override public final void onFailure(Exception e) { ShardSearchFailure f = new ShardSearchFailure(e); - logCCSError(f, clusterAlias, skipUnavailable); if (skipUnavailable) { if (cluster != null) { ccsClusterInfoUpdate(f, cluster, skipUnavailable); @@ -1456,30 +1451,6 @@ private void maybeFinish() { abstract FinalResponse createFinalResponse(); } - /** - * In order to gather data on what types of CCS errors happen in the field, we will log - * them using the ShardSearchFailure XContent (JSON), which supplies information about underlying - * causes of shard failures. - * @param f ShardSearchFailure to log - * @param clusterAlias cluster on which the failure occurred - * @param skipUnavailable the skip_unavailable setting of the cluster with the search error - */ - private static void logCCSError(ShardSearchFailure f, String clusterAlias, boolean skipUnavailable) { - String errorInfo; - try { - errorInfo = Strings.toString(f.toXContent(XContentFactory.jsonBuilder(), ToXContent.EMPTY_PARAMS)); - } catch (IOException ex) { - // use the toString as a fallback if for some reason the XContent conversion to JSON fails - errorInfo = f.toString(); - } - logger.info( - "CCS remote cluster failure. Cluster [{}]. skip_unavailable: [{}]. Error: {}", - clusterAlias, - skipUnavailable, - errorInfo - ); - } - private static RemoteTransportException wrapRemoteClusterFailure(String clusterAlias, Exception e) { return new RemoteTransportException("error while communicating with remote cluster [" + clusterAlias + "]", e); }