Search code examples
javascriptmarklogicmarklogic-11

MarkLogic data movement in the Node.js API - queryAll()


The bug has been resolved as of version 3.3.1.


It's a bug, and a patch release is forthcoming. This workaround —courtesy of Phil Barber, a contributor to the repository — worked for me in the meantime. I appreciate the prompt responses, everyone!

In the meantime, the work-around is to not have the "database" property in the connection settings and to use a REST port with the correct database assigned.

Here's the issue link for anyone who wants to track any updates.


I would greatly appreciate it if someone could share their expertise regarding an issue I'm encountering with queryAll() function in the MarkLogic data movement Node.js API.

I attempted a simple queryAll() example, which resulted in the following error:

MarkLogicError: read forestInfo: cannot process response with 405 status with path.

Is this function currently operational? Do I need to make any additional configuration or permission changes, or install any extra plugins?

The MarkLogic documentation references the queryAll() function, and there's an example query on GitHub. When it comes to reading bulk data, is custom data service a more preferred approach?

Here is some additional context:

const marklogic = require("marklogic");
const connection = require("./settings").connection;
const db = marklogic.createDatabaseClient(connection);
const qb = marklogic.queryBuilder;
const ctsQb = marklogic.ctsQueryBuilder;

const query = qb.where(ctsQb.cts.directoryQuery(["/object/"]));

try {
  db.documents.queryAll(query, {
    onCompletion: (summary) => {
      console.log(summary.urisReadSoFar+' uris were retrieved successfully.');
      console.log(summary.urisFailedToBeRead+' uris failed to be retrieved.');
      console.log('Time taken was '+summary.timeElapsed+' milliseconds.');
    },
  })
} catch (err) {
  console.error("QueryAll Error: ", err);
}
  • I confirmed the simple cts query works in this simpler query example:
const query = qb.where(ctsQb.cts.directoryQuery(["/object/"]));
db.documents.query(query).result(
  (documents) => {
    documents.forEach((doc) => {
      console.log(doc);
    });
    console.log(`${documents.length} uris were retrieved successfully.`);
  },
  (error) => {
    console.log("Error: ", error);
  }
);
  • Additionally, the REST API access log shows the following entry:
127.0.0.1 - admin [28/Jan/2024:17:57:48 -0500] "POST /v1/internal/forestinfo&database=my-db-dev HTTP/1.1" 405 0 - -
  • It's a local MarkLogic 11 instance (not datahub), and the request was run with MarkLogic admin user privileges.

I've only found the limited stuff I mentioned above when looking up this Node.js function. Any help you can give would be great.


Solution

  • We have just released version 3.3.1 of the Node client which fixes this bug.