Skip to main content

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.
The single document referenced by _internal.lineage.source_document_id.
cURL
Python
For a tier-0 document (created directly from a bucket object), parent is absent, because there’s no upstream document. Use root_object instead.
You can request multiple keywords in one call by comma-separating them:
The same 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:
Both endpoints return a 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.
These aliases are equivalent to the underscore-prefixed paths (_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):
If you leave it out, the document is stored as {"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.
Each document stores one span, so no document matches both. Upserted documents have no origin, because the document is the import: count them with _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 using from_object. The result is already structured by collection, and each document’s _internal.lineage.chain tells you where to draw the edges.
For a deeper materialized view (the chain edges with parent/child resolved inline), use the dedicated decomposition tree endpoint:
That endpoint pre-joins everything in one call and is what the Studio namespace detail page uses to draw lineage diagrams.

Limits & caveats

  • Maximum 50 unique user-field references per expand request. This doesn’t apply to lineage keywords (those are bounded by chain length for ancestors and by the children cap for children).
  • expand=children is capped at 100 children per parent. For deeper traversal or wider fan-out, fall back to a from_document filter.
  • Recursive expansion is not supported. expand=parent resolves one level. To walk further, use expand=ancestors (full chain) or call /ancestors then re-expand from there.
  • Lineage is immutable provenance. If an ancestor is deleted, its document_id reference in the chain remains. The ancestors expand silently skips unresolved references and never returns null slots, 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_object and children answer ServiceUnavailableError (HTTP 503), and you retry the request. parent and ancestors fail the request with the store’s error. Neither returns the document without its expansion.