Expand description
Body and query transforms.
Pure transforms with no network or placement lookup: scalar extraction from
a document body, document-_id construction, and tenancy-field
inject/strip. Held to the highest coverage bar including branch coverage
(docs/09).
This crate deliberately depends only on osproxy_core and serde_json:
it speaks in primitives (paths, names, JSON values), and the tenancy adapter
(osproxy-tenancy) translates SPI rule types into these calls. That keeps
the transforms a small, exhaustively testable leaf of the dependency graph.
M2 adds query-DSL filter wrapping (wrap_query, docs/04 §4) and the
logical↔physical id mapping for by-id reads. Bulk NDJSON demux (docs/04
§3) lands in M3 alongside its endpoint.
Structs§
- Bulk
Item - One parsed bulk operation: its action, the optional explicit
_index/_id/routingfrom the action line, and the source document (if any). - Mget
Item - One parsed multi-get fetch: the optional explicit
_index(else the URL default), the document_id, and the optionalrouting. - Msearch
Item - One parsed multi-search request: the optional explicit
indexfrom the header line (else the URL default), and the raw query body line.
Enums§
- Bulk
Action - The action of a bulk operation, mirroring OpenSearch’s verbs.
- Rewrite
Error - A failure applying a body transform.
Functions§
- construct_
id - Expands
templateagainst the resolvedpartitionand the documentdoc. - construct_
id_ bytes - Expands
templateagainst the resolvedpartitionand the raw documentbody, reading{body.<path>}scalars straight from the bytes, without parsingbodyinto aValue(ADR-014). The byte-level twin ofconstruct_idfor the streaming write path. - extract_
scalar - Follows
segmentsintodocand returns the leaf as a string, if the leaf is a scalar (string, number, or bool). - inject_
fields - Inserts each
(name, value)into the top-level object ofdoc. - inject_
fields_ bytes - Splices
fieldsinto the top level of the JSON object inbody, returning the new bytes, without parsingbodyinto aValueor re-serializing it (ADR-014). The body is scanned once for its top-level keys (to reject a spoofed reserved field) and the injected fields are written right after the opening{; the rest of the document is copied verbatim. The byte-level twin ofinject_fieldsfor the streaming write path. - inject_
update - Injects the tenancy fields into the
docandupsertsub-objects of an_updatebody (docs/04§3). - map_
logical_ to_ physical - Maps a client-supplied logical id to the physical id stored in
OpenSearch, by substituting it for the template’s single
{body.<path>}placeholder and expanding{partition}(docs/04§5). - map_
physical_ to_ logical - Maps a physical id back to the client-facing logical id, the inverse
of
map_logical_to_physical, by stripping the template’s literal frame. - parse_
bulk - Parses an NDJSON
_bulkbody into its ordered operations. - parse_
bulk_ action - Parses just the action of a bulk action line, the verb, so a streaming
reader can decide whether a source line follows (
BulkAction::has_source) before it frames the next line (ADR-014 stage 4). Validates the single-key{verb: {…}}shape likeparse_bulk. - parse_
bulk_ op - Parses one bulk operation from its already-framed action line and (for
source-bearing verbs) source line, the per-op entry point for the streaming
demux (ADR-014 stage 4). The source line is kept as raw bytes, validated but
not materialized, exactly as
parse_bulkdoes. - parse_
mget - Parses an
_mgetbody into its ordered fetches. - parse_
msearch - Parses an
_msearchNDJSON body into its ordered searches. - strip_
fields - Removes each named field from the top-level object of
doc, if present. - validate_
json - Validates that
bodyis a single well-formed JSON document, allocating nothing, for the verbatim write path, which forwards the body unchanged but must still reject malformed input. - wrap_
query - Wraps the
queryof a client search body so every match is additionally constrained byfilterterm(s) the client cannot remove.