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

Metadata for a text chunk, tracking byte positions, indices, and page range.

## Fields

  * `:byte_start` - Start byte offset in the original content
  * `:byte_end` - End byte offset in the original content
  * `:token_count` - Optional number of tokens in the chunk
  * `:chunk_index` - Zero-indexed position of this chunk
  * `:total_chunks` - Total number of chunks
  * `:first_page` - Optional first page number covered by this chunk
  * `:last_page` - Optional last page number covered by this chunk
  * `:heading_context` - Optional heading hierarchy for this chunk's section

# `heading_context`

```elixir
@type heading_context() :: %{headings: [heading_level()]}
```

# `heading_level`

```elixir
@type heading_level() :: %{level: non_neg_integer(), text: String.t()}
```

# `t`

```elixir
@type t() :: %Kreuzberg.ChunkMetadata{
  byte_end: non_neg_integer(),
  byte_start: non_neg_integer(),
  chunk_index: non_neg_integer(),
  first_page: non_neg_integer() | nil,
  heading_context: heading_context() | nil,
  last_page: non_neg_integer() | nil,
  token_count: non_neg_integer() | nil,
  total_chunks: non_neg_integer()
}
```

# `from_map`

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

Creates a ChunkMetadata struct from a map.

## Examples

    iex> Kreuzberg.ChunkMetadata.from_map(%{"byte_start" => 0, "byte_end" => 100, "chunk_index" => 0, "total_chunks" => 5})
    %Kreuzberg.ChunkMetadata{byte_start: 0, byte_end: 100, chunk_index: 0, total_chunks: 5}

# `to_map`

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

Converts a ChunkMetadata struct to a map.

---

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