WeaviateEx.GRPC.Services.Batch (WeaviateEx v0.7.4)
View SourcegRPC Batch service for bulk operations.
This module provides high-level functions for batch insert, update, and delete operations using gRPC. Supports both unary and streaming modes.
Usage
{:ok, channel} = WeaviateEx.GRPC.Channel.connect(config)
objects = [
%{collection: "Article", properties: %{title: "First"}},
%{collection: "Article", properties: %{title: "Second"}}
]
{:ok, result} = Batch.insert_objects(channel, objects)
Summary
Functions
Delete multiple objects matching a filter.
Insert multiple objects in a single batch request.
Insert multiple references in a single batch request.
Parse batch result and return failure counts and errors.
Types
Functions
@spec delete_objects(GRPC.Channel.t(), String.t(), map(), batch_opts()) :: {:ok, struct()} | {:error, WeaviateEx.Error.t()}
Delete multiple objects matching a filter.
Examples
filter = %{path: ["category"], operator: :equal, value_text: "old"}
{:ok, result} = Batch.delete_objects(channel, "Article", filter)
@spec insert_objects(GRPC.Channel.t(), [object()], batch_opts()) :: {:ok, struct()} | {:error, WeaviateEx.Error.t()}
Insert multiple objects in a single batch request.
Options
:consistency_level- Consistency level (:one, :quorum, :all):timeout- Request timeout in milliseconds (default: 90000)
Examples
objects = [
%{collection: "Article", properties: %{"title" => "First"}},
%{collection: "Article", properties: %{"title" => "Second"}}
]
{:ok, result} = Batch.insert_objects(channel, objects)
@spec insert_references(GRPC.Channel.t(), [batch_ref()], batch_opts()) :: {:ok, struct()} | {:error, WeaviateEx.Error.t()}
Insert multiple references in a single batch request.
Examples
refs = [
%{from_collection: "Article", from_uuid: "uuid1", from_property: "author", to_uuid: "uuid2"},
%{from_collection: "Article", from_uuid: "uuid3", from_property: "author", to_uuid: "uuid4"}
]
{:ok, result} = Batch.insert_references(channel, refs)
@spec parse_result(struct()) :: %{ failed: non_neg_integer(), errors: [map()], took_ms: float() }
Parse batch result and return failure counts and errors.
Note: The successful count is not directly available from the gRPC reply. Use the object count minus failed count to derive successful count.
Examples
{:ok, reply} = Batch.insert_objects(channel, objects)
%{failed: 2, errors: [...]} = Batch.parse_result(reply)