Compile-time validation for Orkestra.ES.Schema.
This module is invoked from the use Orkestra.ES.Schema macro expansion
(both at __using__ time for the base options and at __before_compile__
time for fields, facets and analysis definitions). Every failure raises an
ArgumentError whose message cites the schema module and the offending
field or definition, so mistakes surface with a clear, actionable message.
It is pure — it never performs I/O and never touches Snap.
Summary
Types
Normalized embed metadata (see compile!/8).
Normalized per-field metadata: %{name:, type:, opts:}.
Functions
Validates fields, facets, embeds and analysis definitions accumulated in the schema.
Validates the base options passed to use Orkestra.ES.Schema.
Types
@type embed_meta() :: %{ name: atom(), schema: module(), cardinality: :one | :many, mode: :object | :nested }
Normalized embed metadata (see compile!/8).
Normalized per-field metadata: %{name:, type:, opts:}.
Functions
@spec compile!( module(), [tuple()], [atom()], [tuple()], keyword(), [atom()], [tuple()], boolean() ) :: {[field_meta()], atom() | nil, [embed_meta()], [atom()]}
Validates fields, facets, embeds and analysis definitions accumulated in the schema.
Returns {field_meta, facets_field, embeds_meta, analyzer_refs} where
field_meta is the normalized list of %{name:, type:, opts:} maps,
facets_field is the atom of the declared facets slot (or nil),
embeds_meta is the normalized list of embed maps (see embed_meta/0), and
analyzer_refs is the deduplicated list of analyzer atoms referenced by the
whole embed tree (used by the root for per-culture coverage validation).
For an embedded schema (embedded? is true) :index/:cultures-only
constructs are forbidden: a settings block, a facets slot, and any
primary_key: true field all raise. Recursive embedding (an embedded schema
that itself embeds another) is allowed. Raises ArgumentError on any
violation.
Validates the base options passed to use Orkestra.ES.Schema.
For an embedded schema (embedded? is true) the root-only options
:index, :cultures and :default_culture are forbidden and raise with a
clear message. Otherwise it enforces that :index is a non-empty string and
that :cultures / :default_culture are mutually consistent (a default
culture is required when cultures are declared and must belong to the list; a
default culture must not be given without cultures).