> ## Documentation Index
> Fetch the complete documentation index at: https://docs.braintrust.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Navigate and filter metadata arrays by index

> [!NOTE]
>
> **Applies to:**
>
> * Plan - Plans: Any
> * Deployment - Deployments: Any
> *
> * Use case - Viewing, filtering, or sorting logs and experiments when metadata contains large arrays and users need to access specific elements by index

## Summary

**Goal:** Filter and inspect metadata array elements by index in logs and experiments.

**Features:** SQL array indexing, custom columns.

## Configuration steps

### Step 1: Use YAML or JSON views to navigate arrays

YAML and JSON views render array items sequentially for easier navigation.

1. Open a log row and locate the metadata field.
2. Switch the field's render mode to **YAML** or **JSON**.
3. Use **Ctrl+F** / **Cmd+F** to search within the rendered text.

### Step 2: Create custom columns for specific array indices

Surface individual array elements as sortable, filterable columns.

1. Select **Display** > **+ Add custom column**.
2. Name the column (e.g., `prompt_0_role`).
3. Enter a SQL expression targeting the index:

```sql theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
metadata.gen_ai.prompt[0].role
metadata.gen_ai.prompt[1].content
```

Once created, filter and sort on these columns directly in the table.

Reference: [View logs – custom columns](https://docs.braintrust.dev/observe/view-logs.md#create-custom-columns)

### Step 3: Filter by array index using SQL

Use the filter bar to query specific array positions. Arrays are 0-based and support negative indices.

```sql theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
-- Match a specific role at index 0
WHERE metadata.gen_ai.prompt[0].role = 'system'

-- Surface a single element as a column
SELECT metadata.gen_ai.prompt[5] AS item_5
```

Reference: [SQL queries](https://docs.braintrust.dev/reference/sql.md)

## Limitations

The metadata viewer has no built-in index jump or next/prev navigation to iterate through arrays, and the steps above are currently to filter and inspect array elements.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.