Scrypath (scrypath v0.3.3)

Copy Markdown View Source

Runtime reflection helpers for searchable schemas declared with use Scrypath.

The initial public reflection surface is intentionally small:

These functions keep reflection under Scrypath.* modules instead of generating schema-specific runtime verbs.

Examples

iex> config = Scrypath.schema_config(SearchablePost)
iex> config.fields
[:title, :body]

Summary

Functions

backfill(schema_module, opts \\ [])

@spec backfill(
  module(),
  keyword()
) :: {:ok, map()} | {:error, term()}

delete_document(schema_module, document_id, opts \\ [])

@spec delete_document(module(), term(), keyword()) :: {:ok, term()} | {:error, term()}

delete_documents(schema_module, document_ids, opts \\ [])

@spec delete_documents(module(), [term()], keyword()) ::
  {:ok, term()} | {:error, term()}

delete_record(schema_module, record, opts \\ [])

@spec delete_record(module(), struct() | map(), keyword()) ::
  {:ok, term()} | {:error, term()}

document_id_field(schema_module)

@spec document_id_field(module()) :: atom()

document_source(schema_module)

@spec document_source(module()) :: atom()

failed_sync_work(schema_module, opts \\ [])

@spec failed_sync_work(
  module(),
  keyword()
) ::
  {:ok, [Scrypath.Operator.FailedWork.t()]}
  | {:ok, Scrypath.Operator.FailedSyncWorkInspection.t()}
  | {:error, term()}

Returns failed or retrying sync work rows for a schema.

Reason class rollups

Pass reason_class_counts: true in operator options (alongside runtime config) to receive {:ok, %Scrypath.Operator.FailedSyncWorkInspection{}} with entries (the row list) and counts — a %Scrypath.Operator.ReasonClassCounts{} with dense per-class frequencies. The default remains {:ok, [FailedWork.t()]} when this option is omitted.

reconcile_sync(schema_module, opts \\ [])

@spec reconcile_sync(
  module(),
  keyword()
) :: {:ok, Scrypath.Operator.Reconcile.t()} | {:error, term()} | {:ok, map()}

reindex(schema_module, opts \\ [])

@spec reindex(
  module(),
  keyword()
) :: {:ok, map()} | {:error, term()}

retry_sync_work(work_or_action, opts \\ [])

@spec retry_sync_work(
  Scrypath.Operator.FailedWork.t() | Scrypath.Operator.RecoveryAction.t(),
  keyword()
) :: {:ok, map()} | {:error, term()}

schema_config(schema_module)

@spec schema_config(module()) :: map()

schema_faceting(schema_module)

@spec schema_faceting(module()) :: keyword()

Returns normalized faceting: options for the schema, or [] when faceting is disabled.

Shape when enabled is a keyword list with :attributes, :max_values_per_facet, and :sort_facet_values_by.

schema_fields(schema_module)

@spec schema_fields(module()) :: [atom()]

schema_settings(schema_module)

@spec schema_settings(module()) :: map()

search(schema_module, text, opts \\ [])

@spec search(module(), String.t(), keyword()) :: {:ok, term()} | {:error, term()}

search!(schema_module, text, opts \\ [])

@spec search!(module(), String.t(), keyword()) :: term()

search_many(entries, opts \\ [])

@spec search_many(
  list(),
  keyword()
) :: {:ok, term()} | {:error, term()}

Federated search across multiple schemas.

Returns an ok tuple whose success value is the library's federated multi-search result struct, or an error tuple on validation, transport, or complete failure.

search_many!(entries, opts \\ [])

@spec search_many!(
  list(),
  keyword()
) :: term()

sync_record(schema_module, record, opts \\ [])

@spec sync_record(module(), struct() | map(), keyword()) ::
  {:ok, term()} | {:error, term()}

sync_records(schema_module, records, opts \\ [])

@spec sync_records(module(), [struct() | map()], keyword()) ::
  {:ok, term()} | {:error, term()}

sync_status(schema_module, opts \\ [])

@spec sync_status(
  module(),
  keyword()
) :: {:ok, Scrypath.Operator.Status.t()} | {:error, term()}