# `Zvex.Collection.Schema.IndexParams`
[🔗](https://github.com/edlontech/zvex/blob/main/lib/zvex/collection/schema/index_params.ex#L1)

Index configuration for a schema field.

Used by `Zvex.Collection.Schema.add_field/4` when the `:index` option is
provided, and by `Zvex.Collection.create_index/3` for runtime index creation.

## Fields

| Field | Applies to | Description |
|---|---|---|
| `:type` | all | **Required.** Index algorithm: `:hnsw`, `:ivf`, `:flat`, or `:invert`. |
| `:metric` | vector | Distance metric: `:l2`, `:ip`, `:cosine`, or `:mipsl2`. |
| `:quantize` | vector | Quantization: `:fp16`, `:int8`, or `:int4`. |
| `:m` | HNSW | Max connections per node (higher = better recall, more memory). |
| `:ef_construction` | HNSW | Build-time search width (higher = better index, slower build). |
| `:n_list` | IVF | Number of inverted-file partitions. |
| `:n_iters` | IVF | K-means training iterations. |
| `:use_soar` | HNSW | Enable SOAR graph optimization. |
| `:enable_range_opt` | invert | Enable range query optimization. |
| `:enable_wildcard` | invert | Enable wildcard/prefix matching. |

# `t`

```elixir
@type t() :: %Zvex.Collection.Schema.IndexParams{
  ef_construction: pos_integer() | nil,
  enable_range_opt: boolean() | nil,
  enable_wildcard: boolean() | nil,
  m: pos_integer() | nil,
  metric: :l2 | :ip | :cosine | :mipsl2 | nil,
  n_iters: pos_integer() | nil,
  n_list: pos_integer() | nil,
  quantize: :fp16 | :int8 | :int4 | nil,
  type: :hnsw | :ivf | :flat | :invert,
  use_soar: boolean() | nil
}
```

Index configuration struct. See module documentation for field details.

# `from_opts`

```elixir
@spec from_opts(keyword()) :: t()
```

Builds an `IndexParams` struct from a keyword list.

The `:type` key is required; all others are optional and default to `nil`
(which lets zvec use its own defaults).

---

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