【问题标题】:Read the large document using marklogic Nodejs API使用 marklogic Nodejs API 阅读大文档
【发布时间】:2015-04-17 05:51:48
【问题描述】:

我正在尝试使用 MarkLogic 的 Node.js 读取 xml/json 文档。我已经从以下 URL 下载了 Node.js API 代码库。

https://github.com/marklogic/node-client-api

它适用于 500KB 等小型文档。但我们的要求是读取大型文档,例如 2 MB 或 10 MB。

对此,我们有两种情况,如下所述:-

案例 1:- 每当我尝试使用 MarkLogic Node.js API 读取文档时,我应该得到不止一个块,但我只得到一个块作为响应。所以由于这个原因它不起作用。

var chunks = 0;
var length = 0;
db.documents.read("test.xml").stream('chunked').
  on('data', function(chunk) {
    console.log(chunk);
    console.log(chunk.length);
    chunks++;
    length += chunk.length;
  }).
  on('error', function(error) {
    console.log(JSON.stringify(error));
  }).
  on('end', function() {
    console.log('read '+chunks+' chunks of '+length+' length');
    console.log('done');
  });

案例 2:- 每当我尝试使用“http-digest-client”包读取一些大文档(如 2 MB 或 10 MB)时,它工作正常,我得到完整的 xml 作为响应。

var digest = require('http-digest-client')('<Username>', '<password>');
digest.request({
  host: '<Host server>',
  path: '/v1/documents?uri=test.xml',
  port: 8007,
  method: 'GET',
}, function (res) {
  reply(res);
});

我已经在下面提到的示例中使用大文档对此进行了测试(请参阅下面的 url),但我得到了与上面案例 1 中描述的相同的响应。

https://github.com/marklogic/node-client-api/blob/develop/examples/read-stream.js#L27

根据我的要求,我想使用 MarkLogic Node.js API 阅读大文档(案例 1)。

  1. 如何使用 MarkLogic Node.js API 读取大型文档?
  2. 是否有任何选项可以增加池内存大小或任何其他内存大小?
  3. 此问题是否与内存大小有关?

【问题讨论】:

    标签: node.js marklogic


    【解决方案1】:

    感谢代码示例。我能够重现该问题。

    请提交针对 MarkLogic Node.js API 的问题:

    https://github.com/marklogic/node-client-api/issues

    【讨论】:

    • 8.0-3 已修复;也就是说,MarkLogic 的最佳实践是处理更小的文档。 (将文档视为一行,将集合视为一个表格。)github.com/marklogic/node-client-api/commit/…
    • 谢谢ehennum。它工作正常。再次感谢:)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-02-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-12-21
    相关资源
    最近更新 更多