# `Kreuzberg.Chunk`
[🔗](https://github.com/kreuzberg-dev/kreuzberg/blob/main/lib/kreuzberg/chunk.ex#L1)

Structure representing a text chunk with embedding for semantic search.

Matches the Rust `Chunk` struct.

## Fields

  * `:content` - The text content of this chunk
  * `:embedding` - Vector embedding (list of floats) for semantic search
  * `:metadata` - ChunkMetadata struct with position and token info
  * `:chunk_type` - Semantic type classification of this chunk (e.g. "heading", "unknown")

# `t`

```elixir
@type t() :: %Kreuzberg.Chunk{
  chunk_type: String.t(),
  content: String.t(),
  embedding: [float()] | nil,
  metadata: Kreuzberg.ChunkMetadata.t()
}
```

# `from_map`

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

Creates a Chunk struct from a map.

## Examples

    iex> Kreuzberg.Chunk.from_map(%{"content" => "chunk text", "embedding" => [0.1, 0.2]})
    %Kreuzberg.Chunk{content: "chunk text", embedding: [0.1, 0.2], metadata: %Kreuzberg.ChunkMetadata{}, chunk_type: "unknown"}

# `new`

```elixir
@spec new(
  String.t(),
  keyword()
) :: t()
```

Creates a new Chunk struct.

## Parameters

  * `content` - The text content of the chunk
  * `opts` - Optional keyword list with `:embedding`, `:metadata`, and `:chunk_type`

# `to_map`

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

Converts a Chunk struct to a map.

---

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