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

# Collections and features

> Create a collection by picking features, start processing, find the feature URI to search, and chain, merge or migrate collections.

A collection reads a source, runs one processing pipeline over it and stores the result as searchable documents. The source is one or more [buckets](https://docs.mixpeek.com/docs/ingest/buckets.md) or another collection. You choose the pipeline by listing **features**, the things you want to search by, such as `image_search` or `faces`. Mixpeek resolves each feature to an [extractor](https://docs.mixpeek.com/docs/extract/extractors.md), pins its version and wires its inputs to your bucket fields.

## Create a collection

This creates a collection that indexes the images in a bucket, then starts processing the objects already in it.

```bash cURL theme={null}
curl -X POST "https://api.mixpeek.com/v1/collections" \
  -H "Authorization: Bearer $MIXPEEK_API_KEY" \
  -H "X-Namespace: $NAMESPACE_ID" \
  -H "Content-Type: application/json" \
  -d '{
    "collection_name": "press-photos",
    "source": { "type": "bucket", "bucket_ids": ["'"$BUCKET_ID"'"] },
    "features": ["image_search"]
  }'
```

```python Python theme={null}
import os
import requests

resp = requests.post(
    "https://api.mixpeek.com/v1/collections",
    headers={
        "Authorization": f"Bearer {os.environ['MIXPEEK_API_KEY']}",
        "X-Namespace": os.environ["NAMESPACE_ID"],
    },
    json={
        "collection_name": "press-photos",
        "source": {"type": "bucket", "bucket_ids": [os.environ["BUCKET_ID"]]},
        "features": ["image_search"],
    },
)
collection = resp.json()
print(collection["collection_id"], collection.get("warnings"))
```

```javascript JavaScript theme={null}
const resp = await fetch("https://api.mixpeek.com/v1/collections", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.MIXPEEK_API_KEY}`,
    "X-Namespace": process.env.NAMESPACE_ID,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    collection_name: "press-photos",
    source: { type: "bucket", bucket_ids: [process.env.BUCKET_ID] },
    features: ["image_search"],
  }),
});
const collection = await resp.json();
console.log(collection.collection_id, collection.warnings);
```

Creating a collection processes nothing by itself. Start it with a trigger, which returns `202` with a `batch_id`, a `task_id` and the `object_count` it picked up:

```bash cURL theme={null}
curl -X POST "https://api.mixpeek.com/v1/collections/$COLLECTION_ID/trigger" \
  -H "Authorization: Bearer $MIXPEEK_API_KEY" \
  -H "X-Namespace: $NAMESPACE_ID"
```

Follow the task with `GET /v1/tasks/{task_id}`. In production, a [sync](https://docs.mixpeek.com/docs/ingest/object-storage.md) on the bucket submits batches as objects land, so you trigger only for on-demand runs. Until a batch runs, objects sit at `PENDING` and the collection has zero documents.

## How a collection works

**Features map to modalities and extractors.** Each feature applies to one or more modalities and is billed in that modality's unit. `GET /v1/collections/features` returns the live menu, with keys, units and rates, and needs no API key.

| Modality | Unit | Base feature | Add-on features |
| - | - | - | - |
| `image` | image | `image_search` | `faces`, `multimodal_understanding` |
| `video` | minute | `video_search` | `faces`, `onscreen_text`, `audio_fingerprint`, `transcript`, `video_transcode`, `multimodal_understanding` |
| `audio` | minute | `audio_search` | `transcript`, `multimodal_understanding` |
| `document` | page | `document_search` | `faces`, `document_layout`, `multimodal_understanding` |
| `text` | token | `text_search` | `multimodal_understanding` |
| `web` | crawled page | `web_crawl` | None |

`storage_only` stores objects without a model. Clustering and taxonomy enrichment are included on every modality. Rates and the cost estimate endpoint are in [Limits and billing](https://docs.mixpeek.com/docs/production/limits-and-billing.md); the [extractor index](https://docs.mixpeek.com/docs/extract/extractors.md) shows which extractor serves each key.

**One pipeline per collection.** A collection runs exactly one extractor. Features that need different extractors, such as a base feature and an add-on marked `companion: true` in the menu, go in separate collections over the same bucket. The create error lists which features group into which collection.

**Inputs are wired for you.** The scaffolded `uploads` bucket has one field per modality: `image`, `video`, `audio`, `pdf`, `content` (text) and `url` (web). A `features` create maps the extractor's inputs to those fields. If your bucket names them differently, the create returns `422` with the fields that exist; rename the field or set `input_mappings` yourself with the [explicit config](https://docs.mixpeek.com/docs/extract/extractors.md#set-extractor-parameters).

**Documents and output schema.** An extractor can split one object into many documents: a video into segments, a PDF into pages or blocks, text into chunks. Each document carries its extractor's fields, the source fields you pass through, and lineage (`root_object_id`, `source_collection_id`, `processing_tier`). The collection's `output_schema` exists as soon as you create it; `GET /v1/collections/{collection_id}/features` lists the feature URIs, types and dimensions before any object is processed.

## Find the feature URI to search

A `feature_search` stage in a [retriever](https://docs.mixpeek.com/docs/retrieve/retrievers.md) names the vector index it searches with a feature URI, in the form `mixpeek://{extractor}@{version}/{model}`. Read it from the collection after you create it:

```bash cURL theme={null}
curl "https://api.mixpeek.com/v1/collections/$COLLECTION_ID" \
  -H "Authorization: Bearer $MIXPEEK_API_KEY" \
  -H "X-Namespace: $NAMESPACE_ID" \
  | jq '.vector_indexes[].feature_uri'
```

> [!WARNING]
>
> The last part of the URI is the model name, for example `gemini-embedding-2`. A wrong URI, such as one ending in `/embedding`, returns no error: the stage matches nothing and the response carries a warning. Copy the URI from `vector_indexes`.

| Feature | Feature URI on a new collection |
| - | - |
| `video_search` | `mixpeek://universal_extractor@v1/gemini-embedding-2` |
| `text_search` | `mixpeek://text_extractor@v1/multilingual_e5_large_instruct_v1` |
| `image_search` | `mixpeek://image_extractor@v1/google_siglip_base_v1` |
| `faces` | `mixpeek://face_identity_extractor@v1/insightface__arcface` |

`video_search` writes one vector per segment that blends picture and speech; the transcript is stored in the `text` field. To search a transcript as its own vector, use the [Multimodal](https://docs.mixpeek.com/docs/extract/extractors.md#multimodal) extractor with `run_transcription_embedding`. On a collection with imported or promoted vectors and no extractor, `feature_uri` is the bare index name, and a `feature_search` stage accepts it as returned.

The URI pins the extractor version, so a retriever built on `v1` keeps working after `v2` ships. You move to a new version on purpose, as described in [Change the model or extractor](#change-the-model-or-extractor).

## Options

### Explicit pipeline config

`feature_extractor` replaces `features` when you need extractor parameters, your own `input_mappings` or `field_passthrough`. Send one or the other. The field shape and every extractor's parameters are on [Extractors](https://docs.mixpeek.com/docs/extract/extractors.md#set-extractor-parameters).

Pass through every field you plan to filter on at query time. A local field filter runs 100 to 1,000 times faster than a stage that reaches back into the bucket.

### Custom features

Extractors you upload keep their own names and are selected as `custom:<plugin_name>`, for example `"features": ["custom:defect_detector"]`. They are priced per unit from the compute profile the extractor declares. See [Custom extractors](https://docs.mixpeek.com/docs/extract/custom-extractors.md).

### Chain collections

A collection whose source is another collection reads that collection's documents. This turns ingestion into a tree: split video into segments, then chunk and embed each segment's transcript, then classify each chunk. Mixpeek assigns each collection a processing tier and runs a tier only after the tier above has written its documents. Re-ingesting an object at the top re-runs the whole chain.

```json Tier 2 collection body theme={null}
{
  "collection_name": "transcript-chunks",
  "source": { "type": "collection", "collection_id": "col_segments" },
  "feature_extractor": {
    "feature_extractor_name": "text_extractor",
    "version": "v1",
    "input_mappings": { "text": "transcription" },
    "field_passthrough": [
      { "source_path": "start_time" },
      { "source_path": "end_time" },
      { "source_path": "root_object_id" }
    ],
    "parameters": { "split_by": "sentences" }
  },
  "taxonomy_applications": [{ "taxonomy_id": "tax_topics" }]
}
```

* Each tier carries forward only the fields you pass through, so pass a field at every tier you need it.
* A tier-1 collection maps bucket fields; a lower tier maps the upper collection's document fields.
* Give vector indexes only to layers you search. A [Multimodal](https://docs.mixpeek.com/docs/extract/extractors.md#multimodal) layer with `run_multimodal_embedding: false` splits video and stores segments with no vector.
* Deleting a tier-1 document removes its descendants.
* Walk the tree with the [Document Lineage API](https://docs.mixpeek.com/docs/api-reference/document-lineage/get-document-lineage.md). To return the parent of a child hit, see [Retriever stages](https://docs.mixpeek.com/docs/retrieve/stages.md).

### Merge buckets with different schemas

A collection can read several buckets. `source.field_map` picks which fields each bucket contributes and what they are called:

```json Merged source theme={null}
{
  "collection_name": "all-creative",
  "source": {
    "type": "bucket",
    "bucket_ids": ["bkt_video_ads", "bkt_static_ads"],
    "field_map": {
      "bkt_video_ads": [{ "source_path": "headline", "target_path": "title" }],
      "bkt_static_ads": [{ "source_path": "name", "target_path": "display_name", "default": "untitled" }]
    }
  },
  "features": ["image_search"]
}
```

Each entry takes `source_path` (required, dot paths allowed), `target_path` (defaults to the last part of `source_path`), `default` and `required`. A bucket with no key in `field_map` passes all of its fields; a bucket mapped to `[]` passes none. A document carries `null` for fields its own bucket did not map. Filter on `root_bucket_id` to select one bucket's documents. Without `field_map`, all fields are merged by name, and two buckets that give one name different types return `422`.

### Build a collection from a retriever pipeline

`retriever_transform` runs retriever stages over the source and writes their outputs as fields, producing a view of the source's documents. Use it to store a classification or score on every document.

```json Transform collection body theme={null}
{
  "collection_name": "scored-scenes",
  "source": { "type": "collection", "collection_id": "col_scenes" },
  "retriever_transform": {
    "stages": [
      {
        "stage_name": "safety",
        "config": { "stage_id": "classify", "parameters": { "task": "nsfw", "document_field": "content" } }
      }
    ],
    "write_back_fields": [
      { "source_field": "classification.label", "target_field": "safety_label" },
      { "source_field": "classification.is_nsfw", "target_field": "flagged" }
    ]
  }
}
```

A collection is extractor-based or transform-based: send `retriever_transform`, or `features`/`feature_extractor`, and you cannot add an extractor later. The transform reads the whole source on each trigger and upserts by document id, so a re-run updates in place. With a `group_by` stage, documents that share the grouped value collapse into one, keeping the highest-scoring. Transform output has no vectors; point an extractor collection at the view to search it by similarity.

### Embedding task

`embedding_task` on the collection sets the task hint for instruction-aware models (E5, Gemini). Indexing defaults to `retrieval_document`, and queries use `retrieval_query` automatically. Set `clustering`, `classification` or `semantic_similarity` only when the collection serves that purpose more than search. Vertex, SigLIP and CLIP vectors ignore it.

## Change the model or extractor

The vector length of an index is fixed when the index is created, and vectors from different models cannot be compared. To move to a new embedding model or extractor version, re-extract into a target namespace and switch over when it checks out. The source namespace stays live, which is your rollback.

**1. Validate the migration**

```bash cURL theme={null}
curl -X POST "https://api.mixpeek.com/v1/namespaces/migrations/validate" \
  -H "Authorization: Bearer $MIXPEEK_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "config": {
      "migration_type": "re_extract",
      "source_namespace_id": "'"$NAMESPACE_ID"'",
      "target_namespace_name": "prod-v2",
      "feature_extractors": [
        { "feature_extractor_name": "multimodal_extractor", "version": "v2" }
      ]
    }
  }'
```

**2. Create and start it**

Send the same `config` to `POST /v1/namespaces/migrations/` with `"start_immediately": true`. Use `filters` to migrate a subset first; re-extraction pays full extraction cost for every document. Follow it with `GET /v1/namespaces/migrations/{migration_id}`.

**3. Compare and switch**

Run your [evaluations](https://docs.mixpeek.com/docs/retrieve/relevance.md) against both namespaces. When the target holds up, send its id in `X-Namespace`. Point back at the source if metrics drop, and retire the source when you no longer need that rollback.

`copy` migrations copy resources without re-extracting, and `extend` adds features to existing documents. To try a new extractor version next to the old one inside one namespace, create a parallel collection on the same bucket and compare retrievers on both feature URIs.

## Limits and errors

> [accordion] 422 on create
>
> * Unknown feature key: the error lists every valid key, plus `custom:<plugin>`.
> * Both `features` and `feature_extractor`, or neither (and no `retriever_transform`).
> * Features that need more than one extractor: the error groups them by collection.
> * Input fields missing from a custom bucket: the error names the fields that exist.
> * Two `field_map` entries that resolve to the same target name, a `field_map` key not in `bucket_ids`, or one field name with different types across buckets. Set `target_path` on nested fields, since `metadata.author` and `content.author` both become `author`.

> [accordion] 201 with warnings
>
> The create succeeds and returns a `warnings` array when a mapped field is declared on the bucket schema and missing from the objects in it. That collection processes nothing until objects carry the field. Fix it on the sync: add a `schema_mapping` whose blob entry sets `blob_property` to the mapped field. The check samples one object and stays quiet on an empty bucket.

> [accordion] Task COMPLETED with 0 documents
>
> The usual causes are an `input_mappings` field the objects do not carry, or, for a custom extractor, wrong `features` keys in its manifest. Check `vector_indexes` on the collection and the object's lineage.

> [accordion] Changes after create
>
> `PATCH` refuses structural fields such as `feature_extractor` and the `windows` split; clone the collection with the new setting instead.

## Old extractor names

Configs that send `feature_extractor` with a built-in name keep working with no end date, and existing collections and feature URIs are unchanged. New collections should use `features`. The [extractor index](https://docs.mixpeek.com/docs/extract/extractors.md) maps each extractor name to its feature key.

## Related

* [Extractors](https://docs.mixpeek.com/docs/extract/extractors.md): inputs, outputs and parameters of each extractor
* [Custom extractors](https://docs.mixpeek.com/docs/extract/custom-extractors.md): run your own model as a feature
* [Buckets](https://docs.mixpeek.com/docs/ingest/buckets.md) and [Object storage and syncs](https://docs.mixpeek.com/docs/ingest/object-storage.md): what a collection reads
* [Retrievers](https://docs.mixpeek.com/docs/retrieve/retrievers.md): search the documents a collection writes
* [Taxonomies](https://docs.mixpeek.com/docs/enrich/taxonomies.md) and [Clusters](https://docs.mixpeek.com/docs/enrich/clusters.md): enrich documents after extraction


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