op.uda( aggColName as String, columndef as String, module as String, function as String, [options as String] ) as aggregatedef
This function processes the values of column for each row in the group or row set with the specified user-defined aggregate as implemented by an aggregate user-defined function (UDF) plugin. The UDF plugin must be installed on each host. The result is used for building the parameters used by the prototype.groupBy function.
For more information on UDF functions, see Aggregate User-Defined Functions in the Application Developer's Guide.
const op = require('/MarkLogic/optic'); const plan1 = op.fromView('main', 'employees') .orderBy(op.schemaCol('main', 'employees', 'EmployeeID')); const plan2 = op.fromView('main', 'expenses') .orderBy(op.schemaCol('main', 'expenses' , 'EmployeeID')); const output = plan1.joinInner(plan2) .where( op.eq( op.schemaCol('main', 'employees' , 'EmployeeID'), op.schemaCol('main', 'expenses', 'EmployeeID') ) ) .groupBy(op.schemaCol('main', 'employees', 'EmployeeID'), op.uda('DetailSum', op.schemaCol('main', 'expenses', 'Amount'), 'sampleplugin/sampleplugin', 'sum')) .orderBy(op.desc(op.col('DetailSum'))) .result(); output;
Stack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.