从示例文档中提取的 Marklogic 错误

Marklogic error taken from sample documents

'use strict'; declareUpdate();
 const es = require('/MarkLogic/entity-services/entity-services.xqy');
 const person = require('/es-gs/person-1.0.0-conv.xqy');
for (const source of fn.collection('raw')) {
  let instance = person.extractInstancePerson(source);
  let uri = '/es-gs/env/' + instance.id + '.xml';
  xdmp.documentInsert(
    uri, person.instanceToEnvelope(instance, "xml"),
    {collections: ['person-envelopes']}
  );
}

我从marklogic网页中获取了以下代码 link to site

我收到以下错误。我正在逐步按照指示进行任何想法

[javascript] XDMP-MODNOTFOUND: const person = require('/es-gs/person-1.0.0-conv.xqy');
 -- Module /es-gs/person-1.0.0-conv.xqy not found
Stack Trace
 At line 4 column 15:

我有/es-gs/person-1.0.0-conv.xqy它存在

Site here

有没有可能是您 deployed the converter module 不小心将转换器模块加载到内容数据库,而不是模块数据库?

Like any application code, the converter module must be deployed to MarkLogic before you can use it. Best practice is to install it in the modules database of your App Server. Our example uses the pre-defined App Server on port 8000, which is configured to use the Modules database.

  1. Open Query Console in your browser if you do not already have it open.
  2. Add a new query to the workspace by clicking on the + button on the query editor.
  3. Select XQuery in the Query Type dropdown.
  4. Select the Modules database from the Database dropdown.
  5. Copy and paste the following code into the new query. This code saves the instance converter module to the database.

我实际上只是犯了那个错误,在尝试重现您的问题时跳过了第 4 步!一旦我将它加载到我的模块数据库中,require 语句就可以毫无错误地找到并加载模块。