Skip to main content

Module metadata_filter

Module metadata_filter 

Source
Expand description

Evaluation of MetadataFilter (nodedb-types) against a document.

One evaluator serves every document shape: a field lookup closure resolves top-level fields. Adapters cover JSON documents (shape sync, vector post-filter), field maps (Lite edge properties) and plain-msgpack maps (Origin edge properties).

Semantics:

  • Eq on a missing field matches only a Null value. Ne negates Eq.
  • Gt/Gte/Lt/Lte are false when the field is missing or null, the value is null, or the pair has no order.
  • In on a missing field is false. NotIn on a missing field is true.
  • And([]) is true. Or([]) is false.

Coercion, one rule for equality and order:

  • Numeric: numbers, decimals, numeric strings and bools (true = 1) compare as numbers. Integer pairs compare exactly.
  • Instant: a typed instant compares with an instant or an ISO-8601 string by epoch microseconds.
  • Text: strings, UUIDs and ULIDs order lexicographically.
  • Any other pair of different kinds is unequal and has no order. So {"score": "n/a"} fails score > 5, and an array fails every order.

Enums§

PropertyMapError
A plain-msgpack property map the evaluator cannot read.

Functions§

matches_all_fields
Every filter of filters against a field map. An empty list admits.
matches_all_msgpack
Every filter of filters against a plain-msgpack map. Decodes only the fields a filter names. Empty bytes evaluate as {}. An empty filter list admits without reading doc.
matches_metadata_fields
filter against a field map (Lite edge properties).
matches_metadata_filter
filter against a JSON document (shape-sync predicates, vector post-filter).
matches_metadata_filter_with
Evaluate filter against a document whose top-level fields lookup resolves.
try_matches_metadata_filter_with
Evaluate filter against a document whose top-level fields lookup resolves. A lookup error stops evaluation and returns that error.