WeaviateEx.API.Batch (WeaviateEx v0.7.4)
View SourceBatch API for Weaviate with gRPC support.
This module powers the public WeaviateEx.Batch wrapper while providing
structured summaries for batch create/delete operations.
When used with a client that has an active gRPC connection, operations use gRPC for optimal performance. Falls back to HTTP otherwise.
Wait for Vector Indexing
After batch operations, vectors are indexed asynchronously. Use
wait_for_vector_indexing/3 to ensure all vectors are queryable:
{:ok, _} = Batch.create_objects(client, objects)
:ok = Batch.wait_for_vector_indexing(client, "Article")
Summary
Functions
Create objects in batch.
Delete objects in batch using match criteria.
Wait for all vectors to be indexed after batch operations.
Types
@type delete_payload() :: map()
@type objects_payload() :: [map()]
@type opts() :: keyword()
@type t() :: WeaviateEx.API.Batch.Result.t()
Functions
@spec create_objects(WeaviateEx.Client.t(), objects_payload(), opts()) :: {:ok, map() | WeaviateEx.API.Batch.Result.t()} | {:error, WeaviateEx.Error.t()}
Create objects in batch.
Uses gRPC when available for optimal performance, falls back to HTTP otherwise.
Pass summary: true to receive a %WeaviateEx.API.Batch.Result{} summary instead of the raw payload.
@spec delete_objects(WeaviateEx.Client.t(), delete_payload(), opts()) :: {:ok, map()} | {:error, WeaviateEx.Error.t()}
Delete objects in batch using match criteria.
Uses gRPC when available for optimal performance, falls back to HTTP otherwise.
@spec wait_for_vector_indexing(WeaviateEx.Client.t(), String.t(), keyword()) :: :ok | {:error, term()}
Wait for all vectors to be indexed after batch operations.
After batch inserts, vectors are indexed asynchronously. This function polls shard status until all vectors are indexed and queryable.
Options
:timeout- Maximum wait time in milliseconds (default: 60_000):poll_interval- Milliseconds between status checks (default: 250):how_many_failures- Number of consecutive failures before giving up (default: 5):tenant- Filter to specific tenant (optional)
Examples
# Wait for all shards in a collection
:ok = Batch.wait_for_vector_indexing(client, "Article")
# Wait with custom timeout
:ok = Batch.wait_for_vector_indexing(client, "Article", timeout: 120_000)
# Wait for specific tenant
:ok = Batch.wait_for_vector_indexing(client, "Article", tenant: "tenant-a")Returns
:ok- All vectors indexed{:error, :timeout}- Timed out waiting for indexing{:error, {:max_failures_exceeded, last_error}}- Too many consecutive failures