WeaviateEx.Reconfigure (WeaviateEx v0.7.4)

View Source

Type-safe configuration update builders for collections.

This module provides builder functions for creating configuration updates that can be passed to Collections.update/3. Each function returns a map with the proper API structure.

Example

alias WeaviateEx.Reconfigure

# Update inverted index settings
updates = Reconfigure.inverted_index(bm25: [b: 0.8, k1: 1.5])

{:ok, _} = WeaviateEx.Collections.update(client, "Article", updates)

# Update replication factor
updates = Reconfigure.replication(factor: 5)

# Combine multiple updates
updates =
  Reconfigure.inverted_index(bm25: [b: 0.8])
  |> Map.merge(Reconfigure.replication(factor: 3))

{:ok, _} = WeaviateEx.Collections.update(client, "Article", updates)

Summary

Functions

Build a description update.

Build an inverted index configuration update.

Merge multiple reconfiguration updates into a single map.

Build a multi-tenancy configuration update.

Build a named vector configuration update.

Build a replication configuration update.

Build an HNSW vector index configuration update.

Functions

description(desc)

@spec description(String.t()) :: map()

Build a description update.

Examples

Reconfigure.description("Updated collection description")

inverted_index(opts \\ [])

@spec inverted_index(keyword()) :: map()

Build an inverted index configuration update.

Options

  • :bm25 - BM25 parameters: [b: float, k1: float]
  • :cleanup_interval_seconds - Seconds between cleanup runs
  • :stopwords - Stopword configuration: [preset: string, additions: [string], removals: [string]]
  • :index_null_state - Whether to index null values (boolean)
  • :index_property_length - Whether to index property length (boolean)
  • :index_timestamps - Whether to index timestamps (boolean)

Examples

# Update BM25 parameters
Reconfigure.inverted_index(bm25: [b: 0.8, k1: 1.5])

# Update cleanup interval
Reconfigure.inverted_index(cleanup_interval_seconds: 120)

# Multiple settings
Reconfigure.inverted_index(
  bm25: [b: 0.75],
  cleanup_interval_seconds: 60,
  index_null_state: true
)

merge(configs)

@spec merge([map()]) :: map()

Merge multiple reconfiguration updates into a single map.

Examples

updates = Reconfigure.merge([
  Reconfigure.inverted_index(bm25: [b: 0.8]),
  Reconfigure.replication(factor: 3),
  Reconfigure.vector_index_hnsw(ef: 128)
])

{:ok, _} = WeaviateEx.Collections.update(client, "Article", updates)

multi_tenancy(opts \\ [])

@spec multi_tenancy(keyword()) :: map()

Build a multi-tenancy configuration update.

Options

  • :auto_tenant_creation - Auto-create tenants on first insert (boolean)
  • :auto_tenant_activation - Auto-activate tenants on access (boolean)

Examples

# Enable auto-tenant creation
Reconfigure.multi_tenancy(auto_tenant_creation: true)

# Enable fully automatic mode
Reconfigure.multi_tenancy(
  auto_tenant_creation: true,
  auto_tenant_activation: true
)

named_vectors_update(name, opts \\ [])

@spec named_vectors_update(
  String.t(),
  keyword()
) :: map()

Build a named vector configuration update.

Updates the configuration for a specific named vector.

Parameters

  • name - Name of the vector to update
  • opts - Vector configuration options (same as vector_index_hnsw)

Examples

# Update a named vector's ef parameter
Reconfigure.named_vectors_update("title_vector", ef: 128)

# Update multiple named vectors
updates =
  Reconfigure.named_vectors_update("title", ef: 128)
  |> Map.merge(Reconfigure.named_vectors_update("content", ef: 256))

replication(opts \\ [])

@spec replication(keyword()) :: map()

Build a replication configuration update.

Options

  • :factor - Replication factor (number of replicas)
  • :async_enabled - Whether async replication is enabled (boolean)
  • :deletion_strategy - Deletion strategy (:no_automated_resolution or :delete_on_conflict)

Examples

# Update replication factor
Reconfigure.replication(factor: 3)

# Enable async replication
Reconfigure.replication(async_enabled: true)

# Set deletion strategy
Reconfigure.replication(deletion_strategy: :delete_on_conflict)

vector_index_hnsw(opts \\ [])

@spec vector_index_hnsw(keyword()) :: map()

Build an HNSW vector index configuration update.

Options

  • :ef - Size of dynamic candidate list for search
  • :ef_construction - Size of candidate list during construction
  • :max_connections - Maximum connections per element
  • :cleanup_interval_seconds - Seconds between cleanup runs
  • :dynamic_ef_factor - Factor for dynamic ef
  • :dynamic_ef_min - Minimum dynamic ef
  • :dynamic_ef_max - Maximum dynamic ef
  • :flat_search_cutoff - Object count threshold for flat search
  • :vector_cache_max_objects - Max objects in vector cache
  • :skip - Skip vector index (boolean)
  • :filter_strategy - Filter strategy (:sweeping or :acorn)

Examples

# Update ef parameters
Reconfigure.vector_index_hnsw(ef: 128, ef_construction: 256)

# Update cache settings
Reconfigure.vector_index_hnsw(vector_cache_max_objects: 100_000)