HasFacetJoinAggregate uses trait:short
Builds the AQL filter fragment for a {@see \oihana\arango\models\enums\Facet::JOIN_AGGREGATE} facet: the key-join counterpart of {@see HasFacetEdgeAggregate} and the aggregate counterpart of {@see HasFacetJoin}. Instead of testing for the mere existence of a joined document, it aggregates a numeric field over ALL joined documents and compares the result to a threshold — `AGG(FOR doc_<key> IN <collection> FILTER doc_<key>.<KEY> == doc.<PROPERTY> RETURN doc_<key>.<field>) <op> @<key>_0`.
The join itself is doc_join.<KEY> == doc.<PROPERTY> (or IN when
AQL::ARRAY is set), with AQL::KEY the joined side (default _key) and
Facet::PROPERTY the main side (default the facet key). The aggregation logic
is shared with HasFacetEdgeAggregate through HasFacetAggregateConditions.
Tags
Table of Contents
Methods
- prepareAggregateConditions() : string
- Builds an aggregate facet expression.
- prepareFacetJoinAggregate() : string
- Prepares a join aggregate facet.
Methods
prepareAggregateConditions()
Builds an aggregate facet expression.
protected
prepareAggregateConditions(mixed $value, array<string|int, mixed> $facet, string $forSource, string|null $prefix, string $docRef, string $key, array<string|int, mixed> &$binds) : string
Resolves the aggregator, field, comparator and threshold (URL overriding
the definition), then emits
AGG(FOR … [FILTER prefix] RETURN related.field) <comparator> @<key>_0.
Parameters
- $value : mixed
-
The facet value: a scalar threshold, or an
{agg, field, op, val}object. - $facet : array<string|int, mixed>
-
The facet definition (
Facet::AGG,AQL::FIELDS,Facet::OP). - $forSource : string
-
The compiled
FOR …source (traversal or collection). - $prefix : string|null
-
An extra condition AND-ed inside the FILTER (e.g. a join match), or null.
- $docRef : string
-
The related-document variable (e.g.
doc_comments). - $key : string
-
The facet key, used to namespace the bind name.
- $binds : array<string|int, mixed>
-
The bind variables, populated by reference.
Tags
Return values
string —The AQL fragment, or an empty string when no threshold is supplied.
prepareFacetJoinAggregate()
Prepares a join aggregate facet.
protected
prepareFacetJoinAggregate(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
-
A scalar threshold, or an
{agg, field, op, val}object. - $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,Facet::AGG,AQL::FIELDS,Facet::OP). - $doc : string
-
The main document reference.