Roy Tang

Programmer, engineer, scientist, critic, gamer, dreamer, and kid-at-heart.

Blog Notes Photos Links Archives About

I want to retrieve all documents in my MarkLogic db that have month=November and also group them by name, and get the count of records per name. I know I can get the frequency per name by using valuesBuilder with a range index on the name field, but how can I filter this result so that I only get the count of records for the month of November?

Supposedly valuesBuilder.fromIndexes().where() can do the filtering, but I don’t know what to pass here and examples online seem to be sparse.


According to the API doc, the where clause takes a queryBuilder.query. With that in mind, you should be able to do something like this (not tested):

var marklogic = require('marklogic');
var vb = marklogic.valuesBuilder;
var qb = marklogic.queryBuilder;
  .where(qb.value('month', 'November'))