Advantages of using this endpoint before a cross-cluster search
editAdvantages of using this endpoint before a cross-cluster search
editYou may want to exclude a cluster or index from a search when:
-
A remote cluster could not be connected to and is configured with
skip_unavailable
=false
. Executing a cross-cluster search under those conditions will cause the entire search to fail. -
A cluster has no matching indices, aliases or data streams for the index expression
(or your user does not have permissions to search them). For example, suppose your
index expression is
logs*,remote1:logs*
and theremote1
cluster has no indices, aliases or data streams that matchlogs*
. In that case, that cluster will return no results from that cluster if you include it in a cross-cluster search. -
The index expression (combined with any query parameters you specify) will likely cause an exception
to be thrown when you do the search. In these cases, the "error" field in the
_resolve/cluster
response will be present. (This is also where security/permission errors will be shown.) - A remote cluster is an older version that does not support the feature you want to use in your search.
Examples
editresp = client.indices.resolve_cluster( name="my-index*,clust*:my-index*", ) print(resp)
response = client.indices.resolve_cluster( name: 'my-index*,clust*:my-index*' ) puts response
const response = await client.indices.resolveCluster({ name: "my-index*,clust*:my-index*", }); console.log(response);
GET /_resolve/cluster/my-index*,clust*:my-index*
The API returns the following response:
{ "(local)": { "connected": true, "skip_unavailable": false, "matching_indices": true, "version": { "number": "8.13.0", "build_flavor": "default", "minimum_wire_compatibility_version": "7.17.0", "minimum_index_compatibility_version": "7.0.0" } }, "cluster_one": { "connected": true, "skip_unavailable": true, "matching_indices": true, "version": { "number": "8.13.0", "build_flavor": "default", "minimum_wire_compatibility_version": "7.17.0", "minimum_index_compatibility_version": "7.0.0" } }, "cluster_two": { "connected": true, "skip_unavailable": false, "matching_indices": true, "version": { "number": "8.13.0", "build_flavor": "default", "minimum_wire_compatibility_version": "7.17.0", "minimum_index_compatibility_version": "7.0.0" } } }
Each cluster has its own response section. The cluster you sent the request to is labelled as "(local)". |
|
The querying cluster attempts to make a request to each remote cluster. If successful, |
|
The |
|
Indicates whether any index, alias or data stream matches the index expression specified for that cluster. |
|
The Elasticsearch server version. |
Identifying potential problems with your cross-cluster search
editThe following request shows several examples of how modifying your query can prevent search failures.
response = client.indices.resolve_cluster( name: 'not-present,clust*:my-index*,oldcluster:*', ignore_unavailable: false ) puts response
GET /_resolve/cluster/not-present,clust*:my-index*,oldcluster:*?ignore_unavailable=false
{ "(local)": { "connected": true, "skip_unavailable": false, "error": "no such index [not_present]" }, "cluster_one": { "connected": true, "skip_unavailable": true, "matching_indices": false, "version": { "number": "8.13.0", "build_flavor": "default", "minimum_wire_compatibility_version": "7.17.0", "minimum_index_compatibility_version": "7.0.0" } }, "cluster_two": { "connected": false, "skip_unavailable": false }, "oldcluster": { "connected": true, "skip_unavailable": false, "matching_indices": true } }
The local cluster has no index called |
|
The |
|
The |
|
The |