Declarative index extractor specifications.
All specs are plain data (tuples of atoms/binaries/integers) — no anonymous
functions. This makes them safe to serialize in the Raft log and snapshots
across code versions without risk of :badfun errors.
Supported Specs
{:map_get, key}— Extract a single map key{:nested, [key1, key2, ...]}— Extract a nested value viaget_in/2{:identity}— Index the entire value as-is{:element, n}— Extract the nth element from a tuple
Examples
# Index on user email field
{:map_get, :email}
# Index on nested field
{:nested, [:address, :city]}
# Index on the raw value
{:identity}
Summary
Functions
Extracts an index value from a stored value using the given spec.
Indexes a value in the given ETS table using the extractor spec. Handles single values and lists of values.
Removes a value from the index ETS table using the extractor spec.
Validates that a given term is a supported extractor spec.
Types
@type spec() :: {:map_get, atom() | binary()} | {:nested, [atom() | binary()]} | {:identity} | {:element, non_neg_integer()}
Functions
Extracts an index value from a stored value using the given spec.
Returns nil if extraction fails or the field doesn't exist.
Indexes a value in the given ETS table using the extractor spec. Handles single values and lists of values.
Removes a value from the index ETS table using the extractor spec.
Validates that a given term is a supported extractor spec.