HasFacetSimpleConditions
Shared builder for the "simple" existential facets ({@see HasFacetEdge}, {@see HasFacetJoin}): both keep documents that have at least one related document (reached by an edge traversal or a key-join) whose field matches the requested value.
Only the iteration source differs (an INBOUND traversal vs a FOR over a
collection plus a join condition), so the value-matching logic lives here:
- the comparison operator is configurable (
Facet::OP, defaulteq, reusing FilterComparator:eq,ne,gt,ge,lt,le,like,match, …), and may be overridden per request with{op, val}; - one or more fields can be searched (
AQL::FIELDS, CSV or list, default_key); a value matches when ANY of the fields satisfies the operator (OR); - comma-separated values are OR-ed; a leading
-negates a value, excluding the document via aLENGTH(...) == 0clause.
Tags
Table of Contents
Methods
- 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
prepareSimpleConditions()
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