WeaviateEx (WeaviateEx v0.7.4)
View SourceA modern Elixir client for Weaviate vector database.
WeaviateEx provides a clean, idiomatic Elixir interface to interact with Weaviate, including support for:
- Collections management (create, read, update, delete)
- Object operations (CRUD with vectors)
- Batch operations for efficient bulk imports
- GraphQL queries for complex searches
- Vector similarity search
- Health checks and monitoring
Configuration
Configure WeaviateEx in your config/config.exs:
config :weaviate_ex,
url: "http://localhost:8080",
api_key: nil # Optional, for authenticated instancesOr use environment variables:
export WEAVIATE_URL=http://localhost:8080
export WEAVIATE_API_KEY=your-api-key # OptionalExamples
# Health check
{:ok, meta} = WeaviateEx.health_check()
# Create a collection
{:ok, collection} = WeaviateEx.Collections.create("Article", %{
properties: [
%{name: "title", dataType: ["text"]},
%{name: "content", dataType: ["text"]}
]
})
# Insert an object
{:ok, object} = WeaviateEx.Objects.create("Article", %{
properties: %{
title: "Hello Weaviate",
content: "This is a test article"
}
})
# Query objects
{:ok, results} = WeaviateEx.Objects.list("Article", limit: 10)
Summary
Functions
Checks if Weaviate is alive (liveness probe).
Returns the API key for authentication, if configured.
Assign roles to an OIDC group.
Returns the configured Weaviate base URL.
Cancel an in-progress backup.
Cancel an ongoing replication.
Get cluster node information.
Get shards for a collection.
Get cluster-wide statistics.
Create a new backup.
Create a role with permissions.
Create a new DB user.
Compare object retrieval via REST and gRPC protocols.
Retrieve object via REST API (bypasses gRPC for debugging).
Delete a replication operation record.
Delete a role.
Delete a user.
Get the status of a backup creation.
Get the current authenticated user.
Get replication operation status.
Get the status of a backup restoration.
Get a role by name.
Get a user by ID.
Performs a health check against the Weaviate instance.
List all backups for a storage backend.
List known OIDC groups.
List all ongoing replications.
List all roles.
List all users.
Checks if Weaviate is ready to serve requests.
Trigger shard replication.
Restore a backup.
Revoke roles from an OIDC group.
Starts an embedded Weaviate instance using the official binary.
Stops an embedded Weaviate instance started with start_embedded/1.
Wait for all replications to complete.
Types
Functions
Checks if Weaviate is alive (liveness probe).
Examples
iex> WeaviateEx.alive?()
{:ok, true}
@spec api_key() :: String.t() | nil
Returns the API key for authentication, if configured.
Assign roles to an OIDC group.
Delegates to WeaviateEx.API.Groups.assign_roles/3.
@spec base_url() :: String.t()
Returns the configured Weaviate base URL.
Cancel an in-progress backup.
Delegates to WeaviateEx.API.Backup.cancel/3.
Examples
:ok = WeaviateEx.cancel_backup(client, "daily-backup", :filesystem)
Cancel an ongoing replication.
Delegates to WeaviateEx.API.Cluster.cancel_replication/2.
Examples
:ok = WeaviateEx.cancel_replication(client, "op-id-123")
Get cluster node information.
Delegates to WeaviateEx.API.Cluster.nodes/2.
Examples
{:ok, nodes} = WeaviateEx.cluster_nodes(client)
{:ok, nodes} = WeaviateEx.cluster_nodes(client, output: "verbose")
Get shards for a collection.
Delegates to WeaviateEx.API.Cluster.shards/2.
Examples
{:ok, shards} = WeaviateEx.cluster_shards(client, "Article")
Get cluster-wide statistics.
Delegates to WeaviateEx.API.Cluster.statistics/1.
Examples
{:ok, stats} = WeaviateEx.cluster_statistics(client)
Create a new backup.
Delegates to WeaviateEx.API.Backup.create/4.
Examples
{:ok, status} = WeaviateEx.create_backup(client, "daily-backup", :filesystem)
{:ok, status} = WeaviateEx.create_backup(client, "daily-backup", :s3,
include_collections: ["Article"],
wait_for_completion: true
)
Create a role with permissions.
Delegates to WeaviateEx.API.RBAC.create_role/3.
Create a new DB user.
Delegates to WeaviateEx.API.Users.create/2.
Compare object retrieval via REST and gRPC protocols.
Delegates to WeaviateEx.Debug.compare_protocols/4.
Examples
{:ok, result} = WeaviateEx.debug_compare(client, "Article", uuid)
if result.match do
IO.puts("Protocols return identical results")
else
IO.puts(WeaviateEx.Debug.ObjectCompare.format_diff(result.differences))
end
Retrieve object via REST API (bypasses gRPC for debugging).
Delegates to WeaviateEx.Debug.get_object_rest/4.
Examples
{:ok, object} = WeaviateEx.debug_get_rest(client, "Article", uuid)
{:ok, object} = WeaviateEx.debug_get_rest(client, "Article", uuid, tenant: "tenant-a")
Delete a replication operation record.
Delegates to WeaviateEx.API.Cluster.delete_replication/2.
Examples
:ok = WeaviateEx.delete_replication(client, "op-id-123")
Delete a role.
Delegates to WeaviateEx.API.RBAC.delete_role/2.
Delete a user.
Delegates to WeaviateEx.API.Users.delete/2.
Get the status of a backup creation.
Delegates to WeaviateEx.API.Backup.get_create_status/3.
Examples
{:ok, status} = WeaviateEx.get_backup_status(client, "daily-backup", :filesystem)
Get the current authenticated user.
Delegates to WeaviateEx.API.Users.get_my_user/1.
Get replication operation status.
Delegates to WeaviateEx.API.Cluster.get_replication/3.
Examples
{:ok, operation} = WeaviateEx.get_replication(client, "op-id-123")
Get the status of a backup restoration.
Delegates to WeaviateEx.API.Backup.get_restore_status/3.
Examples
{:ok, status} = WeaviateEx.get_restore_status(client, "daily-backup", :filesystem)
Get a role by name.
Delegates to WeaviateEx.API.RBAC.get_role/2.
Get a user by ID.
Delegates to WeaviateEx.API.Users.get/2.
@spec health_check() :: api_response()
Performs a health check against the Weaviate instance.
Returns metadata about the Weaviate instance including version, modules, and configuration.
Examples
iex> WeaviateEx.health_check()
{:ok, %{"version" => "1.28.1", "modules" => %{}}}
List all backups for a storage backend.
Delegates to WeaviateEx.API.Backup.list/2.
Examples
{:ok, backups} = WeaviateEx.list_backups(client, :filesystem)
List known OIDC groups.
Delegates to WeaviateEx.API.Groups.list_known/1.
List all ongoing replications.
Delegates to WeaviateEx.API.Cluster.list_replications/2.
Examples
{:ok, replications} = WeaviateEx.list_replications(client)
{:ok, replications} = WeaviateEx.list_replications(client, status: :running)
List all roles.
Delegates to WeaviateEx.API.RBAC.list_roles/1.
List all users.
Delegates to WeaviateEx.API.Users.list_all/1.
Checks if Weaviate is ready to serve requests.
Examples
iex> WeaviateEx.ready?()
{:ok, true}
Trigger shard replication.
Delegates to WeaviateEx.API.Cluster.replicate/4.
Examples
{:ok, operation} = WeaviateEx.replicate_shard(client, "Article", "shard-1",
source_node: "node-1",
target_node: "node-2"
)
Restore a backup.
Delegates to WeaviateEx.API.Backup.restore/4.
Examples
{:ok, status} = WeaviateEx.restore_backup(client, "daily-backup", :filesystem)
{:ok, status} = WeaviateEx.restore_backup(client, "daily-backup", :s3,
wait_for_completion: true
)
Revoke roles from an OIDC group.
Delegates to WeaviateEx.API.Groups.revoke_roles/3.
@spec start_embedded([WeaviateEx.Embedded.option()]) :: {:ok, WeaviateEx.Embedded.Instance.t()} | {:error, term()}
Starts an embedded Weaviate instance using the official binary.
This function delegates to WeaviateEx.Embedded.start/1 and returns an
opaque handle that should be passed to stop_embedded/1 when you're done.
Examples
{:ok, emb} = WeaviateEx.start_embedded(version: "1.30.5", port: 8090)
WeaviateEx.health_check()
:ok = WeaviateEx.stop_embedded(emb)
@spec stop_embedded(WeaviateEx.Embedded.Instance.t()) :: :ok
Stops an embedded Weaviate instance started with start_embedded/1.
Wait for all replications to complete.
Delegates to WeaviateEx.API.Cluster.wait_for_replications/2.
Examples
:ok = WeaviateEx.wait_for_replications(client)
:ok = WeaviateEx.wait_for_replications(client, timeout: 60_000)