Which mechanism to use
Five mechanisms read lineage or group hits by where they came from. They return different things.
See Search a piece, return the whole for a full pipeline that searches segments and returns their parent videos.
Every Mixpeek document carries the full lineage chain that produced it,
from the original bucket object through every transformation. This guide
shows the four patterns for navigating that chain efficiently from the API.
Background on the lineage data model: see Documents → Lineage.
The TL;DR is that each document has
_internal.lineage with root_object_id,
root_bucket_id, source_document_id, and a chain array recording every
processing step.When to use what
The shared rule: never use a list response to grab IDs and then issue per-document
GETs. The
expand parameter takes a comma-separated list, so a single request
fetches the document plus everything you need from its lineage tree.
$expand keywords
Lineage-aware$expand keywords resolve relative to a document’s own
_internal.lineage block. They land under _expanded.<keyword> in the response,
matching the existing user-field expand shape.
- parent
- root_object
- ancestors
- children
The single document referenced by For a tier-0 document (created directly from a bucket object),
_internal.lineage.source_document_id.cURL
Python
parent is
absent, because there’s no upstream document. Use root_object instead.expand is accepted by POST /documents/list (in the request body)
and by retriever response shaping. The document GET endpoint is just the
simplest demonstration.
Convenience endpoints
For SDKs and UIs that want only the lineage walk without fetching the document itself, use the dedicated endpoints:List<DocumentResponse> with the same shape as
GET /documents/{id} per element.
Filter aliases
When you want to search the lineage tree (find every document derived from one root), use the filter aliases instead of expand. They work in document list endpoints, retriever filter stages, and aggregations._internal.lineage.*). They exist purely so you don’t have to learn
the internal schema. Mix them freely with normal user fields:
Provenance: how a document came to exist
Lineage tells you where a document sits. Provenance tells you how it was made. Every document written today carries one record at_internal.provenance, in one of two kinds:
Send
provenance with a document when you upsert it (POST /v1/namespaces/{namespace}/documents/upsert) or create it (POST /v1/collections/{collection_id}/documents):
{"kind": "imported", "source": "api"}. Only extractors write extracted, so sending it returns a 422. A document an extractor produced keeps its provenance: an upsert that sends provenance for it returns a 422, and one that leaves it out keeps the extractor’s record.
Filter, sort and facet on the full path, _internal.provenance.<field>:
Origin: where the piece came from
kind says how the document was made. An extracted document also says where the piece it describes came from, under origin:
The source comes from the object. Send
provenance when you create or upload an object, in the same shape an upsert takes, or give the bucket a default_provenance for the objects that send none:
default_provenance takes source, with optional author and link. An object with neither is recorded as {"source": "api"}.
The span comes from the collection’s split. A collection that writes one document per object (split_method: "whole", split_by: "none") writes whole. One that cuts objects into scenes, segments, chunks, pages or crops writes part, even when a cut happens to cover the whole file. A collection built from another collection keeps its source’s span unless it cuts again, and copies its source’s source, author and link. A source document you upserted lends its own record. A retriever that writes documents copies each source document’s origin.
_internal.provenance.kind = imported. Cluster documents summarise many documents and carry no origin.
There is no short alias for provenance. A field you named provenance yourself, at the document root or in metadata, stays where you put it and filters by its own path (provenance.kind, metadata.provenance.kind). The lineage endpoint (GET /v1/collections/{collection_id}/documents/{document_id}/lineage) returns the record as provenance, whether or not the document has lineage.
Documents written before provenance was recorded have none. The lineage endpoint returns null for them, and a filter on either kind doesn’t match them. Re-extracting the collection writes the record. Documents written before origin was recorded have no origin, and a filter on either span doesn’t match them. Re-extracting writes it. An object uploaded again with different provenance gives the documents of later batches the new origin; documents already written keep theirs until they are re-extracted.
End-to-end example: decomposition tree
To render a decomposition tree for one bucket object (every document at every tier that descended from it), make one filtered list call per collection in the namespace usingfrom_object. The result is
already structured by collection, and each document’s _internal.lineage.chain
tells you where to draw the edges.
Limits & caveats
- Maximum 50 unique user-field references per
expandrequest. This doesn’t apply to lineage keywords (those are bounded by chain length forancestorsand by the children cap forchildren). expand=childrenis capped at 100 children per parent. For deeper traversal or wider fan-out, fall back to afrom_documentfilter.- Recursive expansion is not supported.
expand=parentresolves one level. To walk further, useexpand=ancestors(full chain) or call/ancestorsthen re-expandfrom there. - Lineage is immutable provenance. If an ancestor is deleted, its
document_idreference in the chain remains. Theancestorsexpand silently skips unresolved references and never returnsnullslots, but client code should still be ready for shorter-than-expected chains. - A failed read raises. A missing document is skipped, but a store
read that fails is an error.
root_objectandchildrenanswerServiceUnavailableError(HTTP 503), and you retry the request.parentandancestorsfail the request with the store’s error. Neither returns the document without its expansion.

