Module org.elasticsearch.server
Package org.elasticsearch.action.search
Class SearchResponse.Clusters
java.lang.Object
org.elasticsearch.action.search.SearchResponse.Clusters
- All Implemented Interfaces:
Writeable
,ToXContent
,ToXContentFragment
- Enclosing class:
- SearchResponse
public static final class SearchResponse.Clusters
extends Object
implements ToXContentFragment, Writeable
Holds info about the clusters that the search was executed on: how many in total, how many of them were successful
and how many of them were skipped and further details in a Map of Cluster objects
(when doing a cross-cluster search).
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.elasticsearch.xcontent.ToXContent
ToXContent.DelegatingMapParams, ToXContent.MapParams, ToXContent.Params
Nested classes/interfaces inherited from interface org.elasticsearch.common.io.stream.Writeable
Writeable.Reader<V>, Writeable.Writer<V>
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final ParseField
static final ParseField
static final SearchResponse.Clusters
static final ParseField
static final ParseField
static final ParseField
static final ParseField
static final ParseField
static final ParseField
Fields inherited from interface org.elasticsearch.xcontent.ToXContent
EMPTY_PARAMS
-
Constructor Summary
ConstructorsConstructorDescriptionClusters
(int total, int successful, int skipped) Used for searches that are either not cross-cluster.Clusters
(Map<String, SearchResponse.Cluster> clusterInfoMap) Clusters
(OriginalIndices localIndices, Map<String, OriginalIndices> remoteClusterIndices, boolean ccsMinimizeRoundtrips, Predicate<String> skipUnavailablePredicate) For use with cross-cluster searches.Clusters
(StreamInput in) -
Method Summary
Modifier and TypeMethodDescriptionboolean
getCluster
(String clusterAlias) int
int
getTotal()
boolean
int
hashCode()
boolean
boolean
swapCluster
(String clusterAlias, BiFunction<String, SearchResponse.Cluster, SearchResponse.Cluster> remappingFunction) Utility to swap a Cluster object.toString()
toXContent
(XContentBuilder builder, ToXContent.Params params) void
writeTo
(StreamOutput out) Write this into the StreamOutput.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.elasticsearch.xcontent.ToXContentFragment
isFragment
-
Field Details
-
EMPTY
-
_CLUSTERS_FIELD
-
TOTAL_FIELD
-
SUCCESSFUL_FIELD
-
SKIPPED_FIELD
-
RUNNING_FIELD
-
PARTIAL_FIELD
-
FAILED_FIELD
-
DETAILS_FIELD
-
-
Constructor Details
-
Clusters
public Clusters(@Nullable OriginalIndices localIndices, Map<String, OriginalIndices> remoteClusterIndices, boolean ccsMinimizeRoundtrips, Predicate<String> skipUnavailablePredicate) For use with cross-cluster searches. When minimizing roundtrips, the number of successful, skipped, running, partial and failed clusters is not known until the end of the search and it the information in SearchResponse.Cluster object will be updated as each cluster returns.- Parameters:
localIndices
- The localIndices to be searched - null if no local indices are to be searchedremoteClusterIndices
- mapping of clusterAlias -> OriginalIndices for each remote clusterccsMinimizeRoundtrips
- whether minimizing roundtrips for the CCSskipUnavailablePredicate
- given a cluster alias, returns true if that cluster is skip_unavailable=true and false otherwise
-
Clusters
public Clusters(int total, int successful, int skipped) Used for searches that are either not cross-cluster. For CCS minimize_roundtrips=true useClusters(OriginalIndices, Map<String, OriginalIndices>, boolean)
- Parameters:
total
- total number of clusters in the searchsuccessful
- number of successful clusters in the searchskipped
- number of skipped clusters (skipped can only happen for remote clusters with skip_unavailable=true)
-
Clusters
- Throws:
IOException
-
Clusters
-
-
Method Details
-
writeTo
Description copied from interface:Writeable
Write this into the StreamOutput.- Specified by:
writeTo
in interfaceWriteable
- Throws:
IOException
-
toXContent
public XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params params) throws IOException - Specified by:
toXContent
in interfaceToXContent
- Throws:
IOException
-
getTotal
public int getTotal()- Returns:
- how many total clusters the search was requested to be executed on
-
getClusterStateCount
- Parameters:
status
- the state you want to query- Returns:
- how many clusters are currently in a specific state
-
isCcsMinimizeRoundtrips
- Returns:
- whether this search was a cross cluster search done with ccsMinimizeRoundtrips=true
-
getCluster
- Parameters:
clusterAlias
- The cluster alias as specified in the cluster collection- Returns:
- Cluster object associated with teh clusterAlias or null if not present
-
swapCluster
public SearchResponse.Cluster swapCluster(String clusterAlias, BiFunction<String, SearchResponse.Cluster, SearchResponse.Cluster> remappingFunction) Utility to swap a Cluster object. Guidelines for the remapping function:- The remapping function should return a new Cluster object to swap it for the existing one.
- If in the remapping function you decide to abort the swap you must return the original Cluster object to keep the map unchanged.
- Do not return
null
. If the remapping function returnsnull
, the mapping is removed (or remains absent if initially absent). - If the remapping function itself throws an (unchecked) exception, the exception is rethrown, and the current mapping is left unchanged. Throwing exception therefore is OK, but it is generally discouraged.
- The remapping function may be called multiple times in a CAS fashion underneath, make sure that is safe to do so.
- Parameters:
clusterAlias
- key with which the specified value is associatedremappingFunction
- function to swap the oldCluster to a newCluster- Returns:
- the new Cluster object
-
equals
-
hashCode
public int hashCode() -
toString
-
hasPartialResults
public boolean hasPartialResults()- Returns:
- true if any underlying Cluster objects have PARTIAL, SKIPPED, FAILED or RUNNING status. or any Cluster is marked as timedOut.
-
hasClusterObjects
public boolean hasClusterObjects()- Returns:
- true if this Clusters object was initialized with underlying Cluster objects for tracking search Cluster details.
-
hasRemoteClusters
public boolean hasRemoteClusters()- Returns:
- true if this Clusters object has been initialized with remote Cluster objects This will be false for local-cluster (non-CCS) only searches.
-