简体   繁体   中英

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 . 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. 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

MarkLogic does not store records in an particular order. 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.

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.

It can get a little more involved when you're returning search:search() or cts:search() results, but the underlying logic is similar. 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.

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

Performance guide: https://docs.marklogic.com/guide/performance/order_by

Sort-order in search:search() https://docs.marklogic.com/guide/search-dev/appendixa#id_44212

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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