Skip to main content
A document_structured_extraction record is the persisted output of one LLM structured-extraction pass over a parsed document. It is separate from document_extractions (which stores raw OCR/parser text): this table stores the typed, schema-validated JSON produced after classification and field mapping. The cache key — a composite of document_pk, extraction_family, schema_name, schema_version, prompt_version, model_policy, source_checksum, and evidence_checksum — ensures that retries and backfills reuse existing output without bypassing stale-source or stale-schema guards. Records are scoped to a workspace and hang off a parent document; soft-deletion is used to invalidate superseded cache entries while preserving the audit trail.
Internal object. Not currently exposed on the public REST API. The operations below describe the intended contract.

API operations

Data model

Attributes

Relationships

System-computed

  • document_structured_extraction_id — auto-generated by gen_random_uuid() database default; never supplied by the caller
  • created_at — set to NOW() on INSERT via MikroORM onCreate hook; never updated
  • updated_at — set to NOW() on UPDATE via MikroORM onUpdate hook; NULL on creation
  • deleted_at — set by the extraction pipeline soft-delete path; when set, the partial-unique index uniq_document_structured_extraction_active no longer covers the row, enabling a replacement extraction with the same cache key to be inserted
  • Cache-key deduplication — the partial unique index (document_pk, extraction_family, schema_name, schema_version, prompt_version, model_policy, source_checksum, evidence_checksum) WHERE deleted_at IS NULL guarantees at-most-one live structured extraction per distinct extraction context; the pipeline soft-deletes the old row before inserting a fresh one on invalidation
  • Row written exclusively by the LLM extraction pipeline (ExtractPersistenceService / document structured-extraction service); no user-facing PATCH route exists for this entity

Example

Source: apps/api/src/database/entities/DocumentStructuredExtraction.ts · domain: ingestion · tier: Infrastructure