cts.aggregate( $native-plugin as String, $aggregate-name as String, $range-indexes as cts.reference, [$argument as ValueIterator], [$options as String], [$query as cts.query?], [$forest-ids as String] ) as ValueIterator
Executes a user-defined extension aggregate function against a value lexicon or n-way co-occurence of multiple value lexicons. Value lexicons are implemented using range indexes; consequently this function requires a range index for each lexicon specified in the function. If a specified range index does not exist an error is raised. If the "ordered" or "proximity=" option is specified, the range index must have range value positions set to true, otherwise an error is raised.
|$native-plugin||The path to the native plugin library containing the implementation of the user-defined extension aggregate.|
The name of an aggregate function in |
|$range-indexes||A sequence of references to range indexes. The first range index specified in this or any other aggregate function cannot be of type "nullable".|
|$argument||A sequence containing the arguments for the aggregate function. A map can be used to pass in multiple sequences of arguments.|
options. The default is ().
Only include co-occurrences in fragments selected by the
|$forest-ids||A sequence of IDs of forests to which the search will be constrained. An empty sequence means to search all forests in the database. The default is ().|
Only one of "fragment-frequency" or "item-frequency" may be specified in the options parameter. If neither "fragment-frequency" nor "item-frequency" is specified, then the default is "fragment-frequency".
Only one of "any", "document", "properties", or "locks" may be specified in the options parameter. If none of "any", "document", "properties", or "locks" are specified and there is a $query parameter, then the default is "document". If there is no $query parameter then the default is "any".
Only one of the "checked" or "unchecked" options may be specified in the options parameter. If neither "checked" nor "unchecked" are specified, then the default is "checked".
For details, see Using Aggregate User-Defined Functions in the Search Developer's Guide.
// This query assumes an element range index is configured // in the database for the 'Amount' element and that a plugin module // installed under native/samplePlugin contains a UDF named "myAvg". cts.aggregate("native/samplePlugin, "myAvg", cts.elementReference(xs.QName("Amount"), "type=decimal"), null, ["fragment-frequency","concurrent"]); => 1410.23914666667