WeaviateEx.API.Collections (WeaviateEx v0.7.4)
View SourceCollection (schema) management API.
Summary
Functions
Add property to collection
Create a new collection.
Delete a collection
Delete all collections.
Check if collection exists
Get a specific collection configuration.
Retrieve shard information for a collection.
List all collections.
Enable or disable multi-tenancy for a collection.
Update a collection
Types
@type opts() :: keyword()
Functions
@spec add_property(WeaviateEx.Client.t(), String.t(), map()) :: {:ok, map()} | {:error, WeaviateEx.Error.t()}
Add property to collection
@spec create(WeaviateEx.Client.t(), map(), opts()) :: {:ok, map()} | {:error, WeaviateEx.Error.t()}
Create a new collection.
Examples
config = %{
"class" => "Article",
"vectorizer" => "text2vec-openai",
"properties" => [
%{"name" => "title", "dataType" => ["text"]}
]
}
{:ok, created} = WeaviateEx.API.Collections.create(client, config)Returns
{:ok, map()}- Created collection config{:error, Error.t()}- Error if validation fails or exists
@spec delete(WeaviateEx.Client.t(), String.t()) :: {:ok, map()} | {:error, WeaviateEx.Error.t()}
Delete a collection
@spec delete_all(WeaviateEx.Client.t()) :: {:ok, keyword()} | {:error, WeaviateEx.Error.t()}
Delete all collections.
Examples
{:ok, result} = WeaviateEx.API.Collections.delete_all(client)
# => {:ok, deleted_count: 5}Returns
{:ok, keyword()}- Result with deleted_count and optionally failed_count and failures{:error, Error.t()}- Error if listing collections fails
@spec exists?(WeaviateEx.Client.t(), String.t()) :: {:ok, boolean()}
Check if collection exists
@spec get(WeaviateEx.Client.t(), String.t()) :: {:ok, map()} | {:error, WeaviateEx.Error.t()}
Get a specific collection configuration.
Examples
{:ok, config} = WeaviateEx.API.Collections.get(client, "Article")Returns
{:ok, map()}- Collection configuration{:error, Error.t()}- Error if not found
@spec get_shards(WeaviateEx.Client.t(), String.t(), opts()) :: {:ok, list()} | {:error, WeaviateEx.Error.t()}
Retrieve shard information for a collection.
Supports tenant-aware inspection by passing tenant: "tenant-name" in options.
@spec list(WeaviateEx.Client.t()) :: {:ok, [String.t()]} | {:error, WeaviateEx.Error.t()}
List all collections.
Examples
{:ok, collections} = WeaviateEx.API.Collections.list(client)
["Article", "Author"]Returns
{:ok, [String.t()]}- List of collection names{:error, Error.t()}- Error if request fails
@spec set_multi_tenancy(WeaviateEx.Client.t(), String.t(), boolean(), opts()) :: {:ok, map()} | {:error, WeaviateEx.Error.t()}
Enable or disable multi-tenancy for a collection.
Returns the updated multi-tenancy configuration from the server.
@spec update(WeaviateEx.Client.t(), String.t(), map(), opts()) :: {:ok, map()} | {:error, WeaviateEx.Error.t()}
Update a collection