FacetTrait uses trait:short, trait:short, trait:short, trait:short, trait:short, trait:short, trait:short, trait:short, trait:short, trait:short, trait:short
This trait defines all facet helpers in the Model class.
Table of Contents
Constants
- FACETS : string = 'facets'
- The 'facets' parameter constant.
Properties
- $facets : array<string|int, mixed>|null
- The facet settings.
Methods
- initializeFacets() : static
- Initialize the 'facets' property.
- prepareFacetArrayComplex() : string
- Prepares an array complex facet.
- prepareFacetEdge() : string
- Prepares a facet condition with an edge definition.
- prepareFacetEdgeAggregate() : string
- Prepares an edge aggregate facet.
- prepareFacetEdgeComplex() : string
- Prepares an edge complex facet.
- prepareFacetField() : string
- Prepares a field facet (scalar property comparison, `=~` match by default).
- prepareFacetIn() : string
- Prepares an array membership facet.
- prepareFacetJoin() : string
- Prepares a simple join facet.
- prepareFacetJoinAggregate() : string
- Prepares a join aggregate facet.
- prepareFacetJoinComplex() : string
- Prepares a join complex facet.
- prepareFacetList() : string
- Prepares a list facet (array membership, `ANY IN` by default).
- prepareFacetListField() : string
- Prepares a list field facet (array membership, `ANY IN` by default).
- prepareFacetListFieldSorted() : string
- Prepares a sortable list field facet: same membership as {@see prepareFacetListField()}, plus a `SORT POSITION(...)` clause that ranks the matched documents by the order of the requested values (a value appearing first in the request sorts first).
- prepareFacets() : string|null
- Prepare the query with AQL facets definitions.
- negatedComparator() : string|null
- Returns the negative counterpart of an operator code, or null when it has none (ordering operators, already-negative operators, …).
- prepareFacetFieldBetween() : string
- Builds an inclusive `between` (range) field facet: `(LEFT >= @min && LEFT <= @max)`.
Constants
FACETS
The 'facets' parameter constant.
public
string
FACETS
= 'facets'
Properties
$facets
The facet settings.
public
array<string|int, mixed>|null
$facets
= []
Methods
initializeFacets()
Initialize the 'facets' property.
public
initializeFacets([array<string|int, mixed> $init = [] ]) : static
Parameters
- $init : array<string|int, mixed> = []
Return values
staticprepareFacetArrayComplex()
Prepares an array complex facet.
protected
prepareFacetArrayComplex(string $key, mixed $value, array<string|int, mixed> &$binds[, array<string|int, mixed> $facet = [] ][, string $docRef = AQL::DOC ]) : string
Keeps documents whose embedded array property ($docRef.$key) holds at
least one element matching the requested sub-field conditions, expressed
as an existential traversal LENGTH(FOR e IN $docRef.$key FILTER ... ) > 0.
The value is an object of subField: condition pairs; each condition may
be a single value or a list, and any value may be negated with a leading
- (!=). Negation is inline in the existential, so it keeps documents
having an element that does NOT equal the value (not "exclude the value").
Parameters
- $key : string
-
The facet key, also the embedded array property name.
- $value : mixed
-
The sub-field conditions (object of value or list).
- $binds : array<string|int, mixed>
-
The bind variables, populated by reference.
- $facet : array<string|int, mixed> = []
-
The facet definition (reads a facet-wide
Facet::ALT, applied to every sub-field). - $docRef : string = AQL::DOC
-
The document reference the array is read from (default
doc).
Tags
Return values
stringprepareFacetEdge()
Prepares a facet condition with an edge definition.
protected
prepareFacetEdge(string $key, mixed $value, array<string|int, mixed> &$binds, array<string|int, mixed> $facet, string $doc) : string
Parameters
- $key : string
- $value : mixed
- $binds : array<string|int, mixed>
- $facet : array<string|int, mixed>
- $doc : string
Tags
Return values
stringprepareFacetEdgeAggregate()
Prepares an edge aggregate facet.
protected
prepareFacetEdgeAggregate(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 related-document variable suffix).
- $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::EDGE,Facet::AGG,AQL::FIELDS,Facet::OP). - $doc : string
-
The main document reference.
Tags
Return values
stringprepareFacetEdgeComplex()
Prepares an edge complex facet.
protected
prepareFacetEdgeComplex(string $key, mixed $value, array<string|int, mixed> &$binds, array<string|int, mixed> $facet, string $doc) : string
The value is an object of field: condition pairs, ALL matched on the
SAME inbound vertex (AND). Each field condition may be a single value, a
list of values (OR), and any value may be negated with a leading -.
Because every condition applies to the same traversed vertex, negation
stays inline (!=) inside the existential traversal — {value:"-459"}
keeps documents linked to a vertex whose value != 459, which differs
from the plain HasFacetEdge facet's "not linked to" semantics.
Parameters
- $key : string
- $value : mixed
- $binds : array<string|int, mixed>
- $facet : array<string|int, mixed>
- $doc : string
Tags
Return values
stringprepareFacetField()
Prepares a field facet (scalar property comparison, `=~` match by default).
protected
prepareFacetField(string $key, mixed $value, array<string|int, mixed> &$binds, array<string|int, mixed> $facet, string $doc) : string
The operator defaults to match (regex =~, backward compatible). It can
be set in the facet definition (Facet::OP) or overridden per request
with an {op, val} object. Operator codes reuse FilterComparator.
Parameters
- $key : string
-
The facet key (also the default document property).
- $value : mixed
-
A CSV string, a list, or an
{op, val}object selecting the operator per request. - $binds : array<string|int, mixed>
-
The bind variables, populated by reference.
- $facet : array<string|int, mixed>
-
The facet definition (
Facet::PROPERTY,Facet::OP). - $doc : string
-
The document reference the property is read from.
Tags
Return values
stringprepareFacetIn()
Prepares an array membership facet.
protected
prepareFacetIn(string $key, mixed $value, array<string|int, mixed> &$binds, array<string|int, mixed> $facet, string $doc[, bool $sortable = false ]) : string
Parameters
- $key : string
-
The facet key (also the default document array property).
- $value : mixed
-
Either a CSV string (
"a,b"), a list (["a","b"]) or an{op, val}object selecting the operator per request. - $binds : array<string|int, mixed>
-
The bind variables, populated by reference.
- $facet : array<string|int, mixed>
-
The facet definition (
Facet::PROPERTY,Facet::OP). - $doc : string
-
The document reference the array is read from.
- $sortable : bool = false
-
When true, append
SORT POSITION(...)to order by the requested values.
Tags
Return values
stringprepareFacetJoin()
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
stringprepareFacetJoinAggregate()
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.
Tags
Return values
stringprepareFacetJoinComplex()
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.
Tags
Return values
stringprepareFacetList()
Prepares a list facet (array membership, `ANY IN` by default).
protected
prepareFacetList(string $key, mixed $value, array<string|int, mixed> &$binds, array<string|int, mixed> $facet, string $doc) : string
Accepts a CSV string, a list, or an {op, val} object selecting the
operator per request (FilterArrayComparator).
Parameters
- $key : string
- $value : mixed
- $binds : array<string|int, mixed>
- $facet : array<string|int, mixed>
- $doc : string
Tags
Return values
stringprepareFacetListField()
Prepares a list field facet (array membership, `ANY IN` by default).
protected
prepareFacetListField(string $key, mixed $value, array<string|int, mixed> &$binds, array<string|int, mixed> $facet, string $doc[, bool $sortable = false ]) : string
Historical alias of HasFacetIn::prepareFacetIn() — see that method
for the full operator catalogue (any.in, all.in, none.in, …).
Parameters
- $key : string
- $value : mixed
- $binds : array<string|int, mixed>
- $facet : array<string|int, mixed>
- $doc : string
- $sortable : bool = false
Tags
Return values
stringprepareFacetListFieldSorted()
Prepares a sortable list field facet: same membership as {@see prepareFacetListField()}, plus a `SORT POSITION(...)` clause that ranks the matched documents by the order of the requested values (a value appearing first in the request sorts first).
protected
prepareFacetListFieldSorted(string $key, mixed $value, array<string|int, mixed> &$binds, array<string|int, mixed> $facet, string $doc) : string
Parameters
- $key : string
- $value : mixed
- $binds : array<string|int, mixed>
- $facet : array<string|int, mixed>
- $doc : string
Tags
Return values
stringprepareFacets()
Prepare the query with AQL facets definitions.
protected
prepareFacets(array<string|int, mixed>|null $init[, array<string|int, mixed>|null &$binds = null ][, string $docRef = AQL::DOC ][, string $logicalOperator = Logic::AND ]) : string|null
Parameters
- $init : array<string|int, mixed>|null
- $binds : array<string|int, mixed>|null = null
- $docRef : string = AQL::DOC
- $logicalOperator : string = Logic::AND
Return values
string|nullnegatedComparator()
Returns the negative counterpart of an operator code, or null when it has none (ordering operators, already-negative operators, …).
private
negatedComparator(string $op) : string|null
Parameters
- $op : string
Return values
string|nullprepareFacetFieldBetween()
Builds an inclusive `between` (range) field facet: `(LEFT >= @min && LEFT <= @max)`.
private
prepareFacetFieldBetween(string $key, array<string|int, mixed> $value, array<string|int, mixed> &$binds, array<string|int, mixed> $facet, string $doc, mixed $alt) : string
The compared property is alt-aware (the key-side chain wraps doc.<property>).
An omitted bound drops its side (one-sided range), mirroring the number/string
?filter= semantics; both omitted yields an empty fragment.
Parameters
- $key : string
-
The facet key.
- $value : array<string|int, mixed>
-
The request object (
min,max). - $binds : array<string|int, mixed>
-
The bind variables, populated by reference.
- $facet : array<string|int, mixed>
-
The facet definition (
Facet::PROPERTY). - $doc : string
-
The document reference.
- $alt : mixed
-
The resolved
altparameter (request over definition).