0

我有一个使用 Roxy 配置的 Marklogic 9 项目。我一直在关注这些例子:https ://github.com/marklogic-community/roxy/wiki/Adding-Custom-Build-Steps

基本上,我有一个服务器端 JS 函数,我想在部署内容后调用它。我有这样的事情:

# 然后你会定义你的新方法

  def deploy_content
    # you can optionally call the original
    original_deploy_content

    # do your stuff here
    execute_query(%Q{
      xquery version "1.0-ml";
      xdmp:javascript-eval('var process = require("/ingestion/process.sjs"); process.postDeployContent();')
    },
    :db_name => @properties["ml.app-name"] + "-content")

  end

通过查询控制台执行时,此处调用的 xquery 评估良好。但是当我调用 ml local deploy content 时,我收到以下错误:

ERROR: 500 "Internal Server Error"
ERROR: <html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <title>500 Internal Server Error</title>
    <meta name="robots" content="noindex,nofollow"/>
    <link rel="stylesheet" href="/error.css"/>
  </head>
  <body>
    <span class="error">
      <h1>500 Internal Server Error</h1>
      <dl>
        <dt>XDMP-MODNOTFOUND: var process = require("/ingestion/process.sjs"); process.postDeployContent(); -- Module /ingestion/process.sjs not found</dt>
        <dd></dd>
        <dt>in [anonymous], at 1:14 [javascript]</dt>
        <dd></dd>
        <dt>at 3:6,
in xdmp:eval("var process = require(&amp;quot;/ingestion/process.sjs&amp;quot;); proce...") [javascript]</dt>
        <dd></dd>
        <dt>in /eval, at 3:6 [1.0-ml]</dt>
        <dd></dd>
      </dl>
    </span>
  </body>
</html>

为什么从 app_specific.rb 通过 xquery 运行时找不到模块?

或者......有没有更好的方法从这里调用 JS 模块函数。对不起,我对xquery方面不太熟悉,所以我只是调用了一个JS函数。

4

1 回答 1

2

您需要使用:app_name而不是:db_name,并传入具有文档数据库和模块数据库的正确组合的应用服务器的名称。否则,代码将针对 App-Services 服务器进行评估,该服务器针对开箱即用且通常为空的 Documents 和 Modules 数据库运行。

如果您可以直接提供 SJS 代码,那就太好了,并且只需要对 Roxy 进行有限的更改。为这张票添加权重以推动其优先级:

https://github.com/marklogic-community/roxy/issues/821

于 2017-11-16T16:01:07.697 回答