WeaviateEx.API.Collections (WeaviateEx v0.7.4)

View Source

Collection (schema) management API.

Summary

Functions

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.

Types

opts()

@type opts() :: keyword()

Functions

add_property(client, collection_name, property)

@spec add_property(WeaviateEx.Client.t(), String.t(), map()) ::
  {:ok, map()} | {:error, WeaviateEx.Error.t()}

Add property to collection

create(client, config, opts \\ [])

@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

delete(client, collection_name)

@spec delete(WeaviateEx.Client.t(), String.t()) ::
  {:ok, map()} | {:error, WeaviateEx.Error.t()}

Delete a collection

delete_all(client)

@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

exists?(client, collection_name)

@spec exists?(WeaviateEx.Client.t(), String.t()) :: {:ok, boolean()}

Check if collection exists

get(client, collection_name)

@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

get_shards(client, collection_name, opts \\ [])

@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.

list(client)

@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

set_multi_tenancy(client, collection_name, enabled, opts \\ [])

@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.

update(client, collection_name, updates, opts \\ [])

@spec update(WeaviateEx.Client.t(), String.t(), map(), opts()) ::
  {:ok, map()} | {:error, WeaviateEx.Error.t()}

Update a collection