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

# Search a piece, return the whole

> Split each video into layers, search the scene layer, and return the whole videos the matching scenes came from, with the scenes as evidence.

A search over whole videos ranks a 10-minute video by one embedding for all 10 minutes. A search over scenes finds the 4 seconds that match, but it returns scenes. This pipeline does both. It searches the scene layer and returns each matching scene's whole video. Each video carries the scenes that matched as evidence.

It uses four pieces, all on one manifest:

1. A [multimodal extractor](https://docs.mixpeek.com/docs/processing/extractors/multimodal.md) layer tree: the whole video, its scenes, and fixed short intervals.
2. Embeddings only on the layer you search.
3. [`feature_search`](https://docs.mixpeek.com/docs/retrieval/stages/feature-search) on the scene layer.
4. [`traverse_edge`](https://docs.mixpeek.com/docs/retrieval/stages/traverse-edge#lineage-mode) with `follow: "lineage"` and `include_evidence: true`, which returns the parent videos.

An optional fifth stage, [`llm_enrich`](https://docs.mixpeek.com/docs/retrieval/stages/llm-enrich), sends each returned video to a model.

## The layer tree

Each layer is its own collection. The `videos` collection reads the bucket and writes one document per video. The two child collections read `videos` and split each video again. Every child document records its parent in `_internal.lineage.source_document_id`. The stage walks that link back up.

```mermaid theme={null}
flowchart TD
  O["Bucket object<br/>(one video file)"] --> V["videos<br/>split_method: whole<br/>one document per video<br/>no vectors"]
  V --> S["scenes<br/>split_method: scene<br/>one document per scene<br/>embedded, searched"]
  V --> I["intervals<br/>split_method: time, 1.5 s<br/>one document per interval<br/>no vectors"]
```

| Layer | `split_method` | Documents | Vectors | Read by |
| - | - | - | - | - |
| `videos` | `whole` | One per video, from 0 to its measured duration | None | `traverse_edge` returns them, `llm_enrich` reads their video |
| `scenes` | `scene` | One per detected scene | Multimodal embedding | `feature_search` |
| `intervals` | `time`, `time_split_interval: 1.5` | One per 1.5 s | None | Attribute filters, for example `from_document` |

`time_split_interval` takes fractions of a second, down to 0.1. A layer with `run_multimodal_embedding: false` still writes one document per segment, with `start_time`, `end_time` and lineage. Attribute filters read those documents, and feature search does not.

## Index only the layers you search

An embedding costs processing time and storage on every segment it covers. In this tree, only `scenes` is searched, so only `scenes` embeds. `videos` and `intervals` set `run_multimodal_embedding: false`.

A feature search over a collection with no vector index fails with a 400 that names the collection. Search an embedded layer, and read the others with `attribute_filter` or through lineage.

## The manifest

Apply it with `POST /v1/manifest/apply`. Run it first with `?dry_run=true`, which checks the whole plan and creates nothing.

```yaml theme={null}
version: "1.0"
metadata:
  name: search-across-layers
  description: Search scenes, return the whole videos they came from

namespaces:
  - name: video-library
    description: How-to videos, split into whole, scene and 1.5 s layers
    feature_extractors:
      - name: multimodal_extractor
        version: v1

buckets:
  - name: videos
    namespace: video-library
    description: One object per video
    schema:
      properties:
        video: {type: video, required: true}
        title: {type: string}

collections:
  - name: videos
    namespace: video-library
    description: One document per whole video. Not embedded.
    source: {type: bucket, bucket: videos}
    feature_extractor:
      feature_extractor_name: multimodal_extractor
      version: v1
      input_mappings: {video: video}
      field_passthrough:
        - {source_path: title}
      parameters:
        split_method: whole
        run_multimodal_embedding: false

  - name: scenes
    namespace: video-library
    description: Detected scenes of each video. The searched layer.
    source: {type: collection, collection: videos}
    feature_extractor:
      feature_extractor_name: multimodal_extractor
      version: v1
      input_mappings: {video: video_segment_url}
      field_passthrough:
        - {source_path: title}
      parameters:
        split_method: scene
        run_multimodal_embedding: true

  - name: intervals
    namespace: video-library
    description: Fixed 1.5 s intervals of each video. Not embedded.
    source: {type: collection, collection: videos}
    feature_extractor:
      feature_extractor_name: multimodal_extractor
      version: v1
      input_mappings: {video: video_segment_url}
      parameters:
        split_method: time
        time_split_interval: 1.5
        run_multimodal_embedding: false

retrievers:
  - name: find-videos
    namespace: video-library
    description: Describe a moment and get the whole videos that contain it
    collections: [scenes]
    input_schema:
      query:
        type: text
        required: true
        description: Describe the moment
    stages:
      - stage_name: match_scenes
        stage_type: filter
        config:
          stage_id: feature_search
          parameters:
            searches:
              - feature_uri: "mixpeek://multimodal_extractor@v1/vertex_multimodal_embedding"
                query: {input_mode: text, value: "{{INPUT.query}}"}
                top_k: 50
            final_top_k: 50
      - stage_name: whole_videos
        stage_type: apply
        config:
          stage_id: traverse_edge
          parameters:
            follow: lineage
            target_collection_id: videos
            include_evidence: true
```

`input_schema` is a flat dict keyed by field name. A JSON Schema object with `properties` is refused.

## Search the scenes

`feature_search` runs on the retriever's `collections`, here `scenes` alone. `collection_identifiers` takes a list of collection names or ids. A string, including an `{{INPUT...}}` template, is refused with a 422, because the collections a search reads are fixed when the retriever is created. To search a different set of layers, create one retriever per set.

## Return the whole videos

`traverse_edge` with `follow: "lineage"` climbs from each scene to its document in `videos`. Fifty scene hits from 12 videos return 12 results. Each result is the stored `videos` document, scored by its best scene.

```bash theme={null}
curl -X POST "$API/v1/retrievers/$RETRIEVER_ID/execute" \
  -H "Authorization: Bearer $API_KEY" \
  -H "X-Namespace: $NS" \
  -H "Content-Type: application/json" \
  -d '{"inputs": {"query": "someone replaces a bike chain"}}'
```

Each document in the response carries `_evidence`, one entry per scene that reached it, best first:

```json theme={null}
{
  "status": "completed",
  "warnings": [],
  "documents": [
    {
      "document_id": "doc_video_17",
      "collection_id": "col_videos",
      "title": "Bike maintenance basics",
      "score": 0.82,
      "_evidence": [
        {
          "document_id": "doc_scene_204",
          "collection_id": "col_scenes",
          "score": 0.82,
          "start_time": 312.0,
          "end_time": 318.5,
          "depth": 1,
          "path": [
            {"collection_id": "col_scenes", "document_id": "doc_scene_204"},
            {"collection_id": "col_videos", "document_id": "doc_video_17"}
          ]
        },
        {
          "document_id": "doc_scene_211",
          "collection_id": "col_scenes",
          "score": 0.71,
          "start_time": 344.0,
          "end_time": 351.0,
          "depth": 1,
          "path": [
            {"collection_id": "col_scenes", "document_id": "doc_scene_211"},
            {"collection_id": "col_videos", "document_id": "doc_video_17"}
          ]
        }
      ]
    }
  ]
}
```

`start_time` and `end_time` give the moment inside the video, so a player can open at 312 s. The [traverse edge page](https://docs.mixpeek.com/docs/retrieval/stages/traverse-edge.md#lineage-mode) lists every `_evidence` field.

A scene that cannot reach `videos` is dropped and counted under `stage_statistics.stages.whole_videos.metadata`, with a reason per drop. The run also returns a warning that counts them. If a store read fails, the run fails with a 503 instead of returning fewer videos.

## Optional: ask a model about each video

Add `llm_enrich` after `traverse_edge` to send each returned video to a model. Its `video_field` defaults to `video_segment_url`, which a `whole` document holds for the full video.

```yaml theme={null}
      - stage_name: summarize
        stage_type: enrich
        config:
          stage_id: llm_enrich
          parameters:
            provider: google
            model_name: gemini-2.5-flash
            include_media: true
            prompt: "Name the repair this video shows and list its steps."
            output_field: repair_summary
```

The stage accepts at most `max_candidates` documents, 10 unless you set it. A larger working set is refused before any model call, so cut it with `final_top_k` or a reduce stage first. A video stored outside this namespace's storage is not sent. See [Media per document](https://docs.mixpeek.com/docs/retrieval/stages/llm-enrich.md#media-per-document).

## What each step costs

| Step | What you pay for |
| - | - |
| Ingest, each layer | The extractor processes every video again for each layer. A layer with embeddings off skips the embedding step. Price a batch before you submit it with [estimate cost](https://docs.mixpeek.com/docs/api-reference/bucket-batches/estimate-batch-cost.md). |
| `feature_search` | One billed vector query per entry in `searches`, per run. |
| `traverse_edge` | Store reads only. It calls no model and adds no credits. |
| `llm_enrich` | A charge per document it sends to the model. See [the stage's pricing](https://docs.mixpeek.com/docs/retrieval/stages/llm-enrich.md). |

[Explain](https://docs.mixpeek.com/docs/api-reference/retrievers/explain-retriever-execution-plan.md) prices a retriever's stages before you run it.

## Related

* [Traverse Edge](https://docs.mixpeek.com/docs/retrieval/stages/traverse-edge.md#lineage-mode): every lineage-mode parameter, metadata key and error
* [Lineage Traversal](https://docs.mixpeek.com/docs/retrieval/lineage-traversal.md): which lineage mechanism to use when
* [Decomposition](https://docs.mixpeek.com/docs/processing/decomposition.md): how collections build on each other
* [Multimodal extractor](https://docs.mixpeek.com/docs/processing/extractors/multimodal.md): every split parameter


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