我是 Marklogic 世界的新手。我的程序使用自定义 Java 应用程序每 30 秒查询 Beyond.com 获取 XML 数据源。结果以 XML 格式返回。 Java 应用程序使用 XCC API (Marklogic API) 将检索到的数据插入到单个 XML 文件中的 ML 中。数据大小为每分钟 6 MB,如果应用程序运行一天左右,数据量将以 GB 为单位增长。我不知道需要进行任何管理配置才能将如此大量的数据放入 MarkLogic 中的单个 XML 文件中。有人可以验证我的方法,或者建议我是否必须在管理员级别进行任何配置更改。 XML的结构如下...
<?xml version="1.0" encoding="UTF-8"?>
<moreovercontentdump>
<article id="_6232903453">
<description></description>
<author></author>
<source_category>Local</source_category>
<genre>General</genre>
<publisher></publisher>
<media_type>text</media_type>
<docurl>http://www.ilrestodelcarlino.it</docurl>
<harvest_time>Apr 4 2012 4:28PM</harvest_time>
<valid_time>May 14 2012 4:27PM</valid_time>
</article>
<article id="_6232903453">
<description></description>
<author></author>
<source_category>Local</source_category>
<genre>General</genre>
<publisher></publisher>
<media_type>text</media_type>
<docurl>http://www.ilrestodelcarlino.it</docurl>
<harvest_time>Apr 4 2012 4:28PM</harvest_time>
<valid_time>May 14 2012 4:27PM</valid_time>
</article>
<article id="_6232903453">
<description></description>
<author></author>
<source_category>Local</source_category>
<genre>General</genre>
<publisher></publisher>
<media_type>text</media_type>
<docurl>http://www.ilrestodelcarlino.it</docurl>
<harvest_time>Apr 4 2012 4:28PM</harvest_time>
<valid_time>May 14 2012 4:27PM</valid_time>
</article>
</moreovercontentdump>
最佳答案
查看示例 XML,我认为您可能希望将每篇文章存储在其自己的文档中。您可以编写 FLWOR 表达式来调用 xdmp:document-insert
,或者如果您希望在异步任务中插入每个文档,则可以调用 xdmp:spawn
。
最简单的代码可能如下所示:
for $article in xdmp:http-get($some-url, $options)/moreovercontentdump/article
let $uri := concat('moreover/', $article/@id)
return xdmp:document-insert($uri, $article)
您可以通过重写一些原始 XML 来增强该代码。例如,您可能希望将 harvest_time
和 valid_time
元素重新格式化为 xs:dateTime 格式。这样您就可以在这些值上创建范围索引。
关于marklogic - 在 Marlogic 中存储 XML 数据的最佳方式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10018744/