简体   繁体   English

Marklogic:如何按照在源文件中的顺序将 XML 文档加载到 Marklogic 中

[英]Marklogic: How to load XML documents into Marklogic in the same order as it was ordered in the source file

I'm running a set of xqueries on data stored in marklogic .我正在对存储在marklogic 中的数据运行一组xqueries when I saw the results, I noticed that data records are not ordered in the same order as it was ordered in the file that I have load it from.当我看到结果时,我注意到数据记录的排序顺序与我从中加载它的文件中的排序顺序不同。 I used flow studio for loading my xml documents into marklogic.我使用 flow studio 将我的xml文档加载到 marklogic 中。 I need the files to be in the same order as it was ordered in the source file.我需要文件的顺序与源文件中的顺序相同。 Is there a way to achieve that?有没有办法实现这一目标? OR IF this is not possible sorting documents in in an ascending order will solve my problem.或者,如果这不可能按升序对文档进行排序将解决我的问题。 how to do so?怎么办? NOTE:笔记:
I want to to order xml documents not xquery results我想订购 xml 文档而不是 xquery 结果

MarkLogic does not store records in an particular order. MarkLogic 不以特定顺序存储记录。 That said, as records are ingested, you could add a property or metadata element that could be used.也就是说,在摄取记录时,您可以添加可以使用的属性或元数据元素。 For example, when I load rows from a CSV, I typically make sure each row has a unique, ordered ID if I want to be able to represent the data in that order again.例如,当我从 CSV 加载行时,如果我希望能够再次按该顺序表示数据,我通常会确保每一行都有一个唯一的有序 ​​ID。

Regardless, you're going to need to return ordered results based on the query you use to retrieve the records, as you ask in the second part of your question.无论如何,您将需要根据用于检索记录的查询返回排序结果,正如您在问题的第二部分中所问的那样。

When using FLOWR to query the data, you'll be able to use the order by ascending clause to order the documents by the desired value.使用 FLOWR 查询数据时,您将能够使用order by ascending子句按所需值对文档进行排序。

It can get a little more involved when you're returning search:search() or cts:search() results, but the underlying logic is similar.当您返回 search:search() 或 cts:search() 结果时,它可能会涉及更多内容,但底层逻辑是相似的。 There's important performance considerations when trying to order search results- typically you're going to want a range index on the sort element.尝试对搜索结果进行排序时,有一些重要的性能考虑因素 - 通常您会希望在排序元素上有一个范围索引。 There's plenty of information in the ML documentation, depending on how you're querying the records you want to order. ML 文档中有大量信息,具体取决于您查询要订购的记录的方式。

XQuery order by clause: https://docs.marklogic.com/guide/xquery/langoverview#id_71283 XQuery order by 子句: https : //docs.marklogic.com/guide/xquery/langoverview#id_71283

Performance guide: https://docs.marklogic.com/guide/performance/order_by性能指南: https : //docs.marklogic.com/guide/performance/order_by

Sort-order in search:search() https://docs.marklogic.com/guide/search-dev/appendixa#id_44212搜索中的排序顺序:search() https://docs.marklogic.com/guide/search-dev/appendixa#id_44212

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM