# `Zvex.Config`
[🔗](https://github.com/edlontech/zvex/blob/main/lib/zvex/config.ex#L1)

Configuration builder for zvec initialization.

All fields are optional. `nil` values use zvec defaults.

## Example

    Zvex.Config.new()
    |> Zvex.Config.memory_limit(1_073_741_824)
    |> Zvex.Config.query_threads(4)
    |> Zvex.Config.log(:console, level: :warn)

# `t`

```elixir
@type t() :: %Zvex.Config{
  brute_force_by_keys_ratio: nil | nil | float(),
  invert_to_forward_scan_ratio: nil | nil | float(),
  log:
    nil
    | nil
    | {:console,
       %{optional(:level) =&gt; :debug | :info | :warn | :error | :fatal}},
  memory_limit: nil | nil | integer(),
  optimize_threads: nil | nil | integer(),
  query_threads: nil | nil | integer()
}
```

# `brute_force_by_keys_ratio`

```elixir
@spec brute_force_by_keys_ratio(t(), float()) :: t()
```

Sets the key-count ratio threshold for falling back to brute-force search.

# `invert_to_forward_scan_ratio`

```elixir
@spec invert_to_forward_scan_ratio(t(), float()) :: t()
```

Sets the ratio threshold for switching from inverted index scan to forward scan.

# `log`

```elixir
@spec log(t(), :console, keyword()) :: t()
```

Configures console logging for the zvec engine.

## Options

- `:level` — minimum log level: `:debug`, `:info`, `:warn`, `:error`, or `:fatal`.

# `memory_limit`

```elixir
@spec memory_limit(t(), pos_integer()) :: t()
```

Sets the maximum memory usage in bytes for the zvec engine.

# `new`

```elixir
@spec new() :: t()
```

Creates a new configuration with all fields set to `nil` (zvec defaults).

# `optimize_threads`

```elixir
@spec optimize_threads(t(), pos_integer()) :: t()
```

Sets the number of threads used for index optimization.

# `query_threads`

```elixir
@spec query_threads(t(), pos_integer()) :: t()
```

Sets the number of threads used for query execution.

# `to_native_map`

```elixir
@spec to_native_map(t()) :: map()
```

Converts the configuration to the flat map format expected by the NIF layer.

# `validate`

```elixir
@spec validate(t()) :: {:ok, t()} | {:error, Zvex.Error.t()}
```

Validates the configuration using the Zoi schema. Returns `{:ok, config}` or an error.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
