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

# Navigate and filter metadata arrays by index

export const plans_0 = "Plans: Any"

export const deployments_0 = "Deployments: Any"

export const data_plane_version_0 = undefined

export const use_case_0 = "Use case - Viewing, filtering, or sorting logs and experiments when metadata contains large arrays and users need to access specific elements by index"

<Note>
  **Applies to:**

  * Plan - {plans_0}
  * Deployment - {deployments_0}
  * {data_plane_version_0}
  * {use_case_0}
</Note>

## 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://www.braintrust.dev/docs/observe/view-logs#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://www.braintrust.dev/docs/reference/sql)

## 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.
