WeaviateEx.API.Cluster (WeaviateEx v0.7.4)

View Source

Cluster management operations.

Provides visibility into Weaviate cluster state, node health, and shard replication operations.

Node Operations

Shard Operations

  • shards/2 - Get shard status for a collection

Replication Operations

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

batch_stats()

@type batch_stats() :: %{
  queue_length: non_neg_integer(),
  rate_per_second: float(),
  failed_count: non_neg_integer()
}

opts()

@type opts() :: keyword()

output_verbosity()

@type output_verbosity() :: :minimal | :verbose

Functions

batch_stats(client)

@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

cancel_replication(client, operation_id)

@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

delete_all_replications(client)

@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

delete_replication(client, operation_id)

@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

get_replication(client, operation_id, opts \\ [])

@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

list_replications(client, opts \\ [])

@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

nodes(client, opts \\ [])

@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 (:minimal or :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

query_sharding_state(client, collection, opts \\ [])

@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

replicate(client, collection, shard, opts)

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 (:copy or :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

shards(client, collection)

@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

statistics(client)

@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

wait_for_replications(client, opts \\ [])

@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