
TuplesSearch.aggregate( name as stringOrUDF[] ) as TuplesSearch
Applies one or more aggregates to the tuples. Exclusive with respect to the orderBy(), slice(), map(), and reduce() clauses. The built-in aggregates for tuples support only two indexes.
TuplesSearch.where and
TuplesSearch.withOptions clauses with this method.
You cannot use other query modifiers such as
TuplesSearch.slice or
TuplesSearch.orderBy.
// Use the built-in "correlation" aggregate function.
const jsearch = require('/MarkLogic/jsearch.sjs');
jsearch.tuples(['author','format'])
.aggregate('correlation')
.result();
// Compute a user-defined aggregate over co-occurrence of values in
// the "author" and "format" range indexes. The UDF is a function
// named "count" in the UDF plugin installed in the modules database
// with the path "native/sampleplugin".
const jsearch = require('/MarkLogic/jsearch.sjs');
jsearch.tuples(['author', 'format'])
.aggregate(jsearch.udf('native/sampleplugin', 'count'))
.result();
Stack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.