cts:aggregate( $native-plugin as xs:string, $aggregate-name as xs:string, $range-indexes as cts:reference*, [$argument as item()*], [$options as xs:string*], [$query as cts:query?], [$forest-ids as xs:unsignedLong*] ) as item()*
Executes a user-defined extension aggregate function against a value lexicon or n-way co-occurrence 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.
Parameters | |
---|---|
native-plugin | The path to the native plugin library containing the implementation of the user-defined extension aggregate. |
aggregate-name |
The name of an aggregate function in $native-plugin .
|
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 |
options. The default is ().
Options include:
|
query |
Only include co-occurrences in fragments selected by the
cts:query ,
and compute frequencies from this set of included co-occurrences.
The co-occurrences do not need to match the query, but they must occur in
fragments selected by the query.
The fragments are not filtered to ensure they match the query,
but instead selected in the same manner as
"unfiltered" cts:search
operations. If a string
is entered, the string is treated as a cts:word-query of the
specified string.
|
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.
xquery version "1.0-ml"; (: 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:element-reference(xs:QName("Amount"), "type=decimal"), (),("fragment-frequency","concurrent")) => 1410.23914666667
Stack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.