Skip to main content

key_array_element_clauses

Function key_array_element_clauses 

Source
pub fn key_array_element_clauses(
    clauses: Vec<WhereClause>,
    document_type: DocumentTypeRef<'_>,
    grouped_by_in: bool,
    platform_version: &PlatformVersion,
) -> Result<Vec<WhereClause>, Error>
Expand description

Key the clauses of a count, sum, average, ranked or having request that read the elements of a typed array (protocol version 14) as the index levels of the array are keyed: contains as an equality on one element’s key, containsAny as an in over several. The aggregate surfaces then serve them as any equality or in, each element a group of its own. Every other clause passes through unchanged.

A clause on a typed array must be one of the two, with values that key as its elements, and a clause reading elements must name a typed array (WhereClause::validate_array_element_clause): the marker is gone once a clause is keyed, so this is where the field’s type is judged. grouped_by_in says whether the request is grouped by its In field alone (a containsAny routes as one): only then, and without a range clause, does it answer per element when it reads several ([answers_per_element]). A total over several elements would count a document once per element it holds, so it is refused. The ranked and having surfaces and a count sub-query read one element at most, and pass false.