Posts Photos 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.

# / / notes / #nodejs #marklogic #questions #stackoverflow #software-development / Syndicated: stackexchange / 💬 1

Last modified at: Jan. 17, 2021, 5:12 a.m. Source file


Dave Cassel said...

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'))