Builds the full Elasticsearch index mapping for an Orkestra.ES.Schema.
Produces a string-keyed map ready to hand to Snap.Indexes.create/3, made of
a "settings" block (index-level options plus the per-culture "analysis"
definitions) and a "mappings" block with "dynamic" => "strict" always
injected and one property per declared field.
The module is pure — it only manipulates maps, lists, atoms and strings; it
never performs I/O and has no dependency on Snap. It also exposes
mapping_hash/1, a deterministic SHA-256 fingerprint used by the index
lifecycle to detect mapping drift.
Summary
Functions
Filters analysis definitions applicable to culture.
Builds the complete mapping for culture.
Returns the lowercase hexadecimal SHA-256 of a deterministic serialization
of mapping.
Builds the "properties" map for a set of fields, an optional facets slot,
and a list of embeds.
Functions
Filters analysis definitions applicable to culture.
A definition applies when its for: equals culture or when it has no
for: (shared fallback). For a mono-culture schema (culture == nil) only
the shared fallbacks apply.
@spec build( [Orkestra.ES.Schema.Compiler.field_meta()], atom() | nil, [Orkestra.ES.Schema.Compiler.embed_meta()], keyword(), [tuple()], atom() | nil ) :: map()
Builds the complete mapping for culture.
culture is nil for mono-culture schemas; otherwise it selects the
matching per-culture analysis definitions. A definition without for: acts
as a shared fallback and is always included.
embeds_meta (see Orkestra.ES.Schema.Compiler.embed_meta/0) contributes
one "object"/"nested" property per embed, whose "properties" are built
recursively from the embedded schema (multi-level embeds included).
"dynamic" => "strict" is set only at the mapping top level — Elasticsearch
inherits it down into object and nested properties.
Returns the lowercase hexadecimal SHA-256 of a deterministic serialization
of mapping.
Map keys are sorted recursively before hashing, so the result never depends on map insertion order: identical mappings always hash to the same value and different mappings (e.g. two cultures with different analysis) hash differently.
@spec properties([Orkestra.ES.Schema.Compiler.field_meta()], atom() | nil, [ Orkestra.ES.Schema.Compiler.embed_meta() ]) :: map()
Builds the "properties" map for a set of fields, an optional facets slot,
and a list of embeds.
Each embed becomes %{"type" => "object" | "nested", "properties" => ...}
where the inner properties come from the embedded schema's own fields and
embeds, recursively. Public because it is the recursion step used for every
level of an embed tree.