WeaviateEx.API.Cluster (WeaviateEx v0.7.4)
View SourceCluster management operations.
Provides visibility into Weaviate cluster state, node health, and shard replication operations.
Node Operations
nodes/2- Get all nodes with optional verbositystatistics/1- Get cluster statistics
Shard Operations
shards/2- Get shard status for a collection
Replication Operations
replicate/4- Initiate shard replicationlist_replications/2- List all replication operationsget_replication/3- Get specific replication statuscancel_replication/2- Cancel running replicationdelete_replication/2- Delete completed replication record
Examples
# Get all nodes
{:ok, nodes} = Cluster.nodes(client)
# Get nodes with shard info for specific collection
{:ok, nodes} = Cluster.nodes(client, collection: "Article", output: :verbose)
# Get sharding state for collection
{:ok, shards} = Cluster.shards(client, "Article")
# Replicate a shard to another node
{:ok, op} = Cluster.replicate(client, "Article", "shard-1",
source: "node-1",
target: "node-2",
type: :copy
)
# Check replication status
{:ok, op} = Cluster.get_replication(client, "uuid-123")
Summary
Functions
Get server batch statistics for dynamic batch sizing.
Cancel a replication operation.
Delete all replication operation records.
Delete a completed replication operation record.
Get a specific replication operation.
List all replication operations.
Get cluster nodes.
Query the sharding state of a collection.
Initiate shard replication.
Get shards for a collection.
Get cluster statistics.
Wait for all replications to complete.
Types
@type batch_stats() :: %{ queue_length: non_neg_integer(), rate_per_second: float(), failed_count: non_neg_integer() }
@type opts() :: keyword()
@type output_verbosity() :: :minimal | :verbose
Functions
@spec batch_stats(WeaviateEx.Client.t()) :: {:ok, batch_stats()} | {:error, WeaviateEx.Error.t()}
Get server batch statistics for dynamic batch sizing.
Polls the nodes endpoint to retrieve batch queue statistics, which can be used to dynamically adjust batch sizes.
Examples
{:ok, stats} = Cluster.batch_stats(client)
# => %{queue_length: 42, rate_per_second: 150.5, failed_count: 0}Returns
{:ok, batch_stats()}- Aggregated batch stats from all nodes{:error, Error.t()}- Error if request fails
@spec cancel_replication(WeaviateEx.Client.t(), String.t()) :: :ok | {:error, WeaviateEx.Error.t()}
Cancel a replication operation.
Can only cancel operations that are still in progress (pending or running).
Examples
:ok = Cluster.cancel_replication(client, "uuid-123")Returns
:ok- Operation cancelled{:error, Error.t()}- Error if cancellation fails
@spec delete_all_replications(WeaviateEx.Client.t()) :: :ok | {:error, WeaviateEx.Error.t()}
Delete all replication operation records.
Removes all completed, failed, and cancelled replication records. Running operations are not affected.
Examples
:ok = Cluster.delete_all_replications(client)Returns
:ok- All records deleted{:error, Error.t()}- Error if deletion fails
@spec delete_replication(WeaviateEx.Client.t(), String.t()) :: :ok | {:error, WeaviateEx.Error.t()}
Delete a completed replication operation record.
Can only delete operations that are complete (completed, failed, or cancelled).
Examples
:ok = Cluster.delete_replication(client, "uuid-123")Returns
:ok- Record deleted{:error, Error.t()}- Error if deletion fails
@spec get_replication(WeaviateEx.Client.t(), String.t(), opts()) :: {:ok, WeaviateEx.Cluster.Replication.Operation.t()} | {:error, WeaviateEx.Error.t()}
Get a specific replication operation.
Options
:include_history- Include operation history (default: false)
Examples
{:ok, op} = Cluster.get_replication(client, "uuid-123")
# With operation history
{:ok, op} = Cluster.get_replication(client, "uuid-123", include_history: true)Returns
{:ok, Replication.Operation.t()}- Operation details{:error, Error.t()}- Error if not found
@spec list_replications(WeaviateEx.Client.t(), opts()) :: {:ok, [WeaviateEx.Cluster.Replication.Operation.t()]} | {:error, WeaviateEx.Error.t()}
List all replication operations.
Returns all pending, running, and completed replication operations.
Options
:collection- Filter by collection:shard- Filter by shard:target_node- Filter by target node
Examples
# List all replications
{:ok, ops} = Cluster.list_replications(client)
# Filter by collection
{:ok, ops} = Cluster.list_replications(client, collection: "Article")
# Filter by target node
{:ok, ops} = Cluster.list_replications(client, target_node: "node-2")Returns
{:ok, [Replication.Operation.t()]}- List of operations{:error, Error.t()}- Error if request fails
@spec nodes(WeaviateEx.Client.t(), opts()) :: {:ok, [WeaviateEx.Cluster.Node.t()]} | {:error, WeaviateEx.Error.t()}
Get cluster nodes.
Returns information about all nodes in the cluster including their status, version, and optionally shard information.
Options
:collection- Filter by collection (shows shards for that collection):shard- Filter by shard name:output- Verbosity level (:minimalor:verbose)
Examples
# Get all nodes with minimal info
{:ok, nodes} = Cluster.nodes(client)
# Get nodes with verbose info including stats
{:ok, nodes} = Cluster.nodes(client, output: :verbose)
# Get nodes with shard info for specific collection
{:ok, nodes} = Cluster.nodes(client, collection: "Article")
# Get nodes hosting a specific shard
{:ok, nodes} = Cluster.nodes(client, shard: "shard-0")
# Get nodes with collection and shard filter
{:ok, nodes} = Cluster.nodes(client, collection: "Article", shard: "shard-0")Returns
{:ok, [Node.t()]}- List of nodes{:error, Error.t()}- Error if request fails
@spec query_sharding_state(WeaviateEx.Client.t(), String.t(), opts()) :: {:ok, WeaviateEx.Cluster.ShardingState.t() | nil} | {:error, WeaviateEx.Error.t()}
Query the sharding state of a collection.
Returns information about which shards exist and their replica nodes.
Options
:shard- Filter by specific shard name
Examples
# Get sharding state for collection
{:ok, state} = Cluster.query_sharding_state(client, "Article")
# Filter by specific shard
{:ok, state} = Cluster.query_sharding_state(client, "Article", shard: "shard-0")Returns
{:ok, ShardingState.t()}- Sharding state information{:ok, nil}- Collection or shard not found{:error, Error.t()}- Error if request fails
@spec replicate(WeaviateEx.Client.t(), String.t(), String.t(), opts()) :: {:ok, WeaviateEx.Cluster.Replication.Operation.t()} | {:error, WeaviateEx.Error.t()}
Initiate shard replication.
Copies or moves a shard from one node to another.
Options
:source- Source node name (required):target- Target node name (required):type- Replication type (:copyor:move, default::copy)
Examples
# Copy shard to another node
{:ok, op} = Cluster.replicate(client, "Article", "shard-0",
source: "node-1",
target: "node-2",
type: :copy
)
# Move shard to another node (removes from source)
{:ok, op} = Cluster.replicate(client, "Article", "shard-0",
source: "node-1",
target: "node-2",
type: :move
)Returns
{:ok, Replication.Operation.t()}- Created operation{:error, Error.t()}- Error if replication fails
@spec shards(WeaviateEx.Client.t(), String.t()) :: {:ok, [WeaviateEx.Cluster.Shard.t()]} | {:error, WeaviateEx.Error.t()}
Get shards for a collection.
Returns shard status including vector queue depth for monitoring async vectorization progress.
Examples
{:ok, shards} = Cluster.shards(client, "Article")
# Check if all vectors are indexed
Enum.all?(shards, &Shard.vectors_indexed?/1)
# Check if all shards are ready
Enum.all?(shards, &Shard.ready?/1)Returns
{:ok, [Shard.t()]}- List of shards{:error, Error.t()}- Error if collection not found
@spec statistics(WeaviateEx.Client.t()) :: {:ok, map()} | {:error, WeaviateEx.Error.t()}
Get cluster statistics.
Returns cluster-wide statistics including resource usage and performance metrics.
Examples
{:ok, stats} = Cluster.statistics(client)Returns
{:ok, map()}- Cluster statistics{:error, Error.t()}- Error if request fails
@spec wait_for_replications(WeaviateEx.Client.t(), opts()) :: :ok | {:error, :timeout | {:failed, [WeaviateEx.Cluster.Replication.Operation.t()]}}
Wait for all replications to complete.
Polls replication status until all operations are complete.
Options
:poll_interval- Milliseconds between status checks (default: 1000):timeout- Maximum wait time in milliseconds (default: 300000):collection- Only wait for replications of this collection
Examples
:ok = Cluster.wait_for_replications(client)
:ok = Cluster.wait_for_replications(client, collection: "Article", timeout: 60_000)Returns
:ok- All replications complete{:error, :timeout}- Timed out waiting{:error, {:failed, [Replication.Operation.t()]}}- Some replications failed