3

我是 Marklogic 世界的新手。我的程序使用定制的 Java 应用程序来查询 Also.com 获取 XML 数据提要每 30 秒。结果以 XML 格式返回。Java 应用程序使用 XCC API (Marklogic API) 将检索到的数据插入到 ML 中的单个 XML 文件中。数据大小为每分钟 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>        
4

2 回答 2

7

Looking at the sample XML, I think you will probably want to store each article in its own document. You could write a FLWOR expression to call xdmp:document-insert, or call xdmp:spawn if you would prefer to insert each document in an asynchronous task.

The simplest code might look like this:

for $article in xdmp:http-get($some-url, $options)/moreovercontentdump/article
let $uri := concat('moreover/', $article/@id)
return xdmp:document-insert($uri, $article)

You could enhance that code by rewriting some of the original XML. For example, you might want to reformat the harvest_time and valid_time elements in xs:dateTime format. That way you can create a range index on those values.

于 2012-04-05T02:39:00.603 回答
2

一般来说,如果您将来自Moreover.com 的每个响应存储在MarkLogic 中作为其自己的文档,您会得到更好的服务。在某些方面,在 MarkLogic 内部,文档就像 RDBMS 中的行。

此外,如果您插入其中一个 30 秒,我很难看到每分钟摄取 6MB。你遗漏了一些细节吗?

于 2012-04-05T01:01:22.757 回答