HasFacetJoin uses trait:short
Builds the AQL filter fragment for a {@see Facet::JOIN} facet: the key-join counterpart of {@see HasFacetEdge}. Instead of an edge traversal, it joins a collection by attribute equality and keeps documents that have at least one joined document whose field matches the requested value.
Like EDGE, the match is driven by HasFacetSimpleConditions — a
configurable operator (Facet::OP, default eq) over one or more joined-doc
fields (AQL::FIELDS, default _key), with multi-value OR and - negation.
Difference with HasFacetJoinComplex: JOIN is "simple" — the value is a
scalar/CSV matched against one field (or several in OR). JOIN_COMPLEX takes an
object {field: condition} and matches SEVERAL fields AND-ed on the same
joined document.
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).
Tags
Table of Contents
Methods
- prepareFacetJoin() : string
- Prepares a simple join facet.
- prepareSimpleConditions() : string
- Builds a simple existential facet expression.
- simpleLength() : string
- Wraps a set of OR-ed term groups into `LENGTH(FOR … FILTER [prefix &&] (…) RETURN …)`.
Methods
prepareFacetJoin()
Prepares a simple join facet.
protected
prepareFacetJoin(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, CSV string, list, or
{op, val}object matched against the joined field(s). - $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,AQL::FIELDS,Facet::OP). - $doc : string
-
The main document reference.
Tags
Return values
stringprepareSimpleConditions()
Builds a simple existential facet expression.
protected
prepareSimpleConditions(mixed $value, array<string|int, mixed> $facet, string $forSource, string|null $prefix, string $docRef, string $key, array<string|int, mixed> &$binds, string $return) : string
Positive values are matched inside a LENGTH(FOR … FILTER [prefix &&] (… OR …) …) > 0 clause; negated values are excluded with a twin
LENGTH(…) == 0 clause; both are AND-ed (and parenthesized) when present.
Parameters
- $value : mixed
-
The facet value: a scalar, a CSV string, a list, or an
{op, val}object. - $facet : array<string|int, mixed>
-
The facet definition (
Facet::OP,AQL::FIELDS). - $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_location). - $key : string
-
The facet key, used to namespace the bind names.
- $binds : array<string|int, mixed>
-
The bind variables, populated by reference.
- $return : string
-
The compiled
RETURN …clause.
Tags
Return values
stringsimpleLength()
Wraps a set of OR-ed term groups into `LENGTH(FOR … FILTER [prefix &&] (…) RETURN …)`.
private
simpleLength(string $forSource, string|null $prefix, array<int, string> $groups, string $return) : string
Parameters
- $forSource : string
- $prefix : string|null
- $groups : array<int, string>
- $return : string