Oihana PHP Arango

HasFacetEdgeComplex uses trait:short

Builds the AQL filter fragment for an {@see Facet::EDGE_COMPLEX} facet: like {@see HasFacetEdge} it keeps documents linked through an inbound edge traversal, but matches SEVERAL fields on the same target vertex (AND), each field accepting multiple values (OR) and per-value negation. Composed into the model via {@see FacetTrait}.

Tags
see
FacetTrait::prepareFacets()

The dispatcher that invokes this builder.

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`.
prepareFacetEdgeComplex()  : string
Prepares an edge 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: condition pairs.

$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 alt chain (from Facet::ALT), applied to every sub-field; null for none.

Tags
throws
BindException
UnsupportedOperationException
ValidationException
Return values
array<int, string>

The AQL conditions (to AND together).

prepareFacetEdgeComplex()

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
throws
BindException
ReflectionException
UnsupportedOperationException
ValidationException
example

Set the facetable definition in the model :

Arango::FACETS =>
[
    Prop::NUMBERS =>
    [
        Facet::TYPE => Facet::EDGE_COMPLEX,
        Facet::EDGE => 'livestocks_has_numbers'
    ]
]

Use the facet :

?facets={"numbers":{"value":"459875642"}}            // value == 459875642
?facets={"numbers":{"value":"459","kind":"ear"}}     // value == 459 AND kind == ear (same vertex)
?facets={"numbers":{"value":["459","460"]}}          // value == 459 OR value == 460
?facets={"numbers":{"value":"-459","kind":"ear"}}    // value != 459 AND kind == ear (same vertex)
?facets={"numbers":{"value":["459","-460"]}}         // value == 459 AND value != 460
Return values
string
On this page

Search results