MarkLogic node.js API-分组并按计数排序 [英] MarkLogic node.js api - group by and sort by count

查看:63
本文介绍了MarkLogic node.js API-分组并按计数排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在关系数据库中,您会遇到类似从mytable组中按c desc的名称顺序选择名称,count(1)as c"的内容.基本上,我想统计包含每个名称值的记录数,并首先获取计数最高的记录.

In a relational db you'd have something like "select name, count(1) as c from mytable group by name order by c desc". Basically I want to count how many records contain each name value and get the ones with highest counts first.

是否可以使用Node.js API在Marklogic中做类似的事情?

Is there a way to do a similar thing in Marklogic using the Node.js API?

推荐答案

类似的方法应该起作用:

Something like this should work:

var marklogic = require('marklogic');
var my = require('./my-connection.js');

var db = marklogic.createDatabaseClient(my.connInfo);
var vb = marklogic.valuesBuilder;

db.values.read(
  vb.fromIndexes('name')
    .withOptions({values: ['descending', 'frequency-order']});

查询节点的Lexicons和Range Indexs部分.js Application Developer's Guide将提供更多详细信息.

The Querying Lexicons and Range Indexes section of the Node.js Application Developer's Guide will provide more detail.

这篇关于MarkLogic node.js API-分组并按计数排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆