Loads the current source records for search document ids.
Oban sync jobs carry document ids, not document data. When a job runs, it loads the records as they are now, so a retried or delayed job never sends an older copy over newer index data.
By default the loader queries the schema by its document_id field with the
configured :repo, then applies the schema's declared preload::
use Scrypath,
fields: [:name, :category_name],
preload: [:category]A schema that needs full control, for example tenant-scoped repos, soft
deletes, or document ids that are not a column, defines search_records/2.
It receives the document ids and a context map with :repo, and returns the
records that still exist and should be searchable:
def search_records(ids, %{repo: repo}) do
from(p in __MODULE__, where: p.id in ^ids, preload: :category)
|> repo.all(skip_tenant_id: true)
endIds with no returned record are removed from the index.
Summary
Functions
Checks that records for schema_module can be loaded by document id.
Whether the schema defines its own search_records/2 loader.
Raises when records for schema_module cannot be loaded by document id.
Returns {:ok, records, missing_ids} for the given document ids.
Functions
Checks that records for schema_module can be loaded by document id.
Returns {:error, :search_records_required} for schemas with custom document
ids and no search_records/2, and {:error, :repo_required} when no :repo
is configured.
Whether the schema defines its own search_records/2 loader.
Raises when records for schema_module cannot be loaded by document id.
Called before an Oban job is queued so a missing repo or an unmappable custom document id fails at the call site instead of inside the worker.
Returns {:ok, records, missing_ids} for the given document ids.
missing_ids keeps the caller's id values for documents whose records no
longer exist.