Converts between an Orkestra.ES.Schema struct and its Elasticsearch
document representation.
to_doc/4 turns a struct into a string-keyed map ready for indexing;
from_hit/5 rebuilds the struct from an _source map. The two are inverse
for valid values, so from_hit(to_doc(struct)) == struct.
Casting rules:
Date/DateTimevalues serialize to ISO8601 and are parsed back based on the runtime value (a string containing"T"is read as aDateTime, otherwise as aDate). A field declared with a customformat:keeps its raw string on the way back, since the library cannot interpret arbitrary ES date patterns.nilvalues are preserved asnull, keeping the round-trip faithful.- The facets slot is flattened on write (one entry per value) and
regrouped on read (by
attr_code, preserving the first-seen order andattr_name); read values always getcount: nil. - Embeds recurse through the embedded schema's own
to_doc/1/from_hit/1(multi-level embeds included): anembeds_onevalue ofnilstaysnull; anembeds_manylist maps element-wise, and a missing/nullarray reads back as[].
The module is pure and has no dependency on Snap.
Summary
Functions
Rebuilds a schema struct of module from an Elasticsearch _source map.
Converts a schema struct into a string-keyed Elasticsearch document.
Functions
@spec from_hit( map(), module(), [Orkestra.ES.Schema.Compiler.field_meta()], atom() | nil, [ Orkestra.ES.Schema.Compiler.embed_meta() ] ) :: struct()
Rebuilds a schema struct of module from an Elasticsearch _source map.
@spec to_doc(struct(), [Orkestra.ES.Schema.Compiler.field_meta()], atom() | nil, [ Orkestra.ES.Schema.Compiler.embed_meta() ]) :: map()
Converts a schema struct into a string-keyed Elasticsearch document.