Oihana PHP Arango

HasFacetArrayComplex

Builds the AQL filter fragment for a {@see Facet::ARRAY_COMPLEX} facet: it keeps documents whose embedded array property holds at least one element matching the requested sub-field conditions. Composed into the model via {@see FacetTrait}.

Tags
see
FacetTrait::prepareFacets()

The dispatcher that invokes this builder.

Table of Contents

Methods

prepareFacetArrayComplex()  : string
Prepares an array complex facet.

Methods

prepareFacetArrayComplex()

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

Set the facetable definition in the model :

Arango::FACETS =>
[
    Prop::WORKSHOPS =>
    [
        Facet::TYPE => Facet::ARRAY_COMPLEX
    ]
]

Use the facet :

?facets={"workshops":{"breeding.alternateName":"pig"}}            // an element with breeding.alternateName == pig
?facets={"workshops":{"breeding.alternateName":["pig","cattle"]}} // an element == pig OR == cattle
?facets={"workshops":{"breeding.alternateName":["-pig","cattle"]}}// an element != pig AND != cattle
Return values
string
On this page

Search results