在Marlogic中存储XML数据的最佳方式

Pan*_*kaj 3 marklogic

我是Marklogic世界的新手.我的程序使用自定义Java应用程序每30秒查询一次Further.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>        
Run Code Online (Sandbox Code Playgroud)

mbl*_*ele 7

查看示例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)
Run Code Online (Sandbox Code Playgroud)

您可以通过重写一些原始XML来增强该代码.例如,您可能希望以xs:dateTime格式重新格式化元素harvest_timevalid_time元素.这样您就可以在这些值上创建范围索引.