0

我现在想在浏览我得到的文档时在推送数据时添加上下文名称是这样的:-

{{
    "key1": "test1",
    "key2": "test2",
    "key3": "test3",
    "key4": "test4."
}}

我想要的其他地方是:-

{
  "RouterAnomalyData":{
    "key1": "test1",
    "key2": "test2",
    "key3": "test3",
    "key4": "test4."
  }
}

请指教??

4

1 回答 1

0

我曾希望该-delimited_root_name选项可以满足您的需求,但这仅适用于 XML。我已经在 GitHub 上提交了添加该功能的请求。同时,您需要使用 MLCP 转换。请参阅在摄取期间转换输入。您的函数将如下所示:

function yourTransform(content, context)
{
  // content.value is a document node. Convert to an object 
  // and wrap it with the new property. 
  const newDoc = {
     "RouterAnomalyData": content.value.toObject()
  }

  // Update the content with the new document. 
  content.value = xdmp.unquote(xdmp.quote(newDoc));

  return content;
}

然后,您可以安装转换在摄取期间调用转换。这应该会导致您正在寻找的结构。

于 2017-09-19T11:36:03.587 回答