Skip to content

OpticsIndexedDocument

An indexed document tracks the state of one document in the Azure AI Search index — how many chunks it produced, whether indexing succeeded, and when it last ran.

The searchable copy of a document lives in Azure, not in this database. This row is the local record of that copy: it lets staff see what has been indexed, spot failures, and re-run indexing. source_hash records the content the index was built from, so reconciliation can tell whether a document has changed since it was last indexed.

Written by the indexing jobs and observed from the admin panel.

  • app/Jobs/IndexDocumentJob.php — creates and updates the row as it chunks and uploads a document.
  • app/Jobs/ReconcileOpticsIndexJob.php — compares local rows against the remote index and repairs drift.
  • app/Services/Voice/Tools/ReadKnowledgeBaseDocument.php — resolves a search hit back to its source document.
  • app/Filament/Resources/OpticsIndexedDocumentResource.php — staff view status and errors.
Relation Type Related model
documentText belongsTo DocumentText
organization belongsTo Organization

attachment_id is stored but has no declared relation method on this model.

Table: optics_indexed_documents.

Column Type Notes
id uuid Primary key
organization_id uuid Nullable FK to organizations, null on delete
document_text_id uuid Unique; FK to document_texts, cascade delete
attachment_id uuid Nullable
title string Nullable
chunk_count unsigned int Cast to integer, defaults to 0
status string pending, indexing, indexed, failed
source_hash string Nullable; hash of indexed content
error text Nullable; last failure message
indexed_at timestamp Nullable, cast to datetime
created_at, updated_at timestamp

organization_id and status carry a composite index.