TuplesSearch.aggregate

TuplesSearch.aggregate(
   name as stringOrUDF[]
) as TuplesSearch

Summary

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.

Parameters
name One or an array of built-in aggregate function names or aggregate user-defined function (UDF) reference. The allowed built-in aggregate names are "correlation", "covariance", and "covariancep". To construct UDF reference, use the jsearch.udf helper function.

Usage Notes

You can only use the TuplesSearch.where and TuplesSearch.withOptions clauses with this method. You cannot use other query modifiers such as TuplesSearch.slice or TuplesSearch.orderBy.

See Also

Example


// Use the built-in "correlation" aggregate function.
const jsearch = require('/MarkLogic/jsearch.sjs');
jsearch.tuples(['author','format'])
  .aggregate('correlation')
  .result();
   

Example


// 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();
   
Powered by MarkLogic Server | Terms of Use | Privacy Policy