HasFacetJoinComplex uses trait:short
Builds the AQL filter fragment for a {@see Facet::JOIN_COMPLEX} facet: the key-join counterpart of {@see HasFacetEdgeComplex}. Instead of traversing an edge, it joins a collection by attribute equality and keeps documents that have at least one joined document matching SEVERAL fields (AND), each field accepting multiple values (OR) and per-value negation.
A join is a nested FOR matched on a key, not a graph traversal:
LENGTH(FOR doc_<key> IN <collection> FILTER doc_<key>.<KEY> == doc.<PROPERTY> && …conditions… RETURN 1) > 0. The join is doc_join.<KEY> == doc.<PROPERTY>
(or IN when the main document holds an array of keys), with KEY the joined
side (default _key) and PROPERTY the main side (default the facet key) —
which expresses both "the document holds the foreign key" and the reverse
one-to-many "the joined documents reference the document".
Tags
Table of Contents
Methods
- prepareComplexConditions() : array<int, string>
- Builds the list of AQL conditions for an object of `field: condition` pairs, each tested on the related document `$docRef`.
- prepareFacetJoinComplex() : string
- Prepares a join complex facet.
Methods
prepareComplexConditions()
Builds the list of AQL conditions for an object of `field: condition` pairs, each tested on the related document `$docRef`.
protected
prepareComplexConditions(mixed $value, string $docRef, string $key, array<string|int, mixed> &$binds[, mixed $alt = null ]) : array<int, string>
Every condition applies to the same related document, so per-value
negation stays inline (!=) and a field given an array OR-es its values
(flipping to AND when a negative term is present, mirroring HasFacetField).
Each sub-field name is validated with assertAttributeName() before
being interpolated, guarding against AQL injection.
A facet-wide alt (from the definition) wraps EVERY sub-field comparison
symmetrically — its key-side chain wraps each related field, its value-side
chain wraps each bound value (e.g. LOWER(v.value) == LOWER(@0)). Per
sub-field alt is not (yet) supported — see static::prepareComplexConditions().
Parameters
- $value : mixed
-
The object of
field: conditionpairs. - $docRef : string
-
The related-document variable (e.g.
doc_numbers). - $key : string
-
The facet key, used to namespace the bind names.
- $binds : array<string|int, mixed>
-
The bind variables, populated by reference.
- $alt : mixed = null
-
The facet-wide
altchain (fromFacet::ALT), applied to every sub-field; null for none.
Tags
Return values
array<int, string> —The AQL conditions (to AND together).
prepareFacetJoinComplex()
Prepares a join complex facet.
protected
prepareFacetJoinComplex(string $key, mixed $value, array<string|int, mixed> &$binds, array<string|int, mixed> $facet, string $doc) : string
Parameters
- $key : string
-
The facet key (also the default main-side join property).
- $value : mixed
-
The object of
field: conditionpairs tested on the joined document. - $binds : array<string|int, mixed>
-
The bind variables, populated by reference.
- $facet : array<string|int, mixed>
-
The facet definition (
AQL::COLLECTION,AQL::KEY,Facet::PROPERTY,AQL::ARRAY). - $doc : string
-
The main document reference.