Loading TOC...

MarkLogic 12 EA 2 Product Documentation
cts.avgAggregate

cts.avgAggregate(
   range-index as cts.reference,
   [options as String[]],
   [query as cts.query?],
   [forest-ids as (Number|String)[]]
) as xs.anyAtomicType?

Summary

Returns the average of the values given a value lexicon. This function works like cts:avg except it performs the calculation in parallel in all data nodes then aggregates the values. It generally performs better than cts:avg, especially on large clusters.

Parameters
range-index Reference to a range index.
options Same as the "options" parameter in cts:aggregate.
query Same as the "query" parameter in cts:aggregate.
forest-ids Same as the "forest-ids" parameter in cts:aggregate.

Example

//   This query assumes an element range index is configured
//   in the database for the 'Amount' element.

cts.avgAggregate(cts.elementReference(xs.QName("Amount")));

=> 122.2933333333333355

Stack Overflow iconStack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.