Oihana PHP Arango

HasFacetListField

Builds the AQL filter fragment for an {@see Facet::LIST_FIELD} (and {@see Facet::LIST_FIELD_SORTED}) facet. Kept as a thin alias over the {@see HasFacetIn} primitive (operator defaults to `any.in`), preserving the historical type names. Composed into the model via {@see FacetTrait}.

Tags
see
HasFacetIn::prepareFacetIn()

The membership primitive these delegate to.

FacetTrait::prepareFacets()

The dispatcher that invokes this builder.

Table of Contents

Methods

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).

Methods

prepareFacetListField()

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
throws
BindException
example

Set the facetable definition in the model :

Arango::FACETS =>
[
    Prop::KEYWORDS =>
    [
        Facet::TYPE     => Facet::LIST_FIELD ,
        Facet::PROPERTY => Prop::KEYWORDS
    ]
]

Use the facet (array membership tested against doc.keywords) :

?facets={"keywords":"cuisine,jardin"}                        // ANY IN  : has cuisine OR jardin
?facets={"keywords":["cuisine","jardin"]}                    // ANY IN  : array form, same result
?facets={"keywords":{"op":"all.in","val":"cuisine,jardin"}}  // ALL IN  : has BOTH
?facets={"keywords":{"op":"none.in","val":"cuisine"}}        // NONE IN : has NEITHER

Generated AQL (default any.in) :

TO_ARRAY([@keywords_0,@keywords_1]) ANY IN doc.keywords
Return values
string

prepareFacetListFieldSorted()

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
throws
BindException
example

Set the facetable definition in the model :

Arango::FACETS =>
[
    Prop::TAGS =>
    [
        Facet::TYPE     => Facet::LIST_FIELD_SORTED ,
        Facet::PROPERTY => Prop::TAGS
    ]
]

Use the facet — keep articles tagged featured, new or sale, ranked in that priority order :

?facets={"tags":"featured,new,sale"}
?facets={"tags":["featured","new","sale"]}

Generated AQL :

TO_ARRAY([@tags_0,@tags_1,@tags_2]) ANY IN doc.tags SORT POSITION([@tags_0,@tags_1,@tags_2],doc.tags,true)
Return values
string
On this page

Search results