Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
245 views
in Technique[技术] by (71.8m points)

xquery - Read documents in order

We have a list of URIs and which we need to read in the sequence in which it is passed.

Example1

doc(("/doc1", "/doc2", "/doc3"))

above function should return the content of "/doc1" then "/doc2" and then "/doc3" but it is not happening.

The same thing is happening is with the below query also.

Example2

cts:search(doc(), cts:document-query((("/doc1"),("/doc2"),("/doc3"))))

What will be the solution if I want to read the documents in which sequence I pass the URIs ?

Any help is appreciated..!

question from:https://stackoverflow.com/questions/66061532/read-documents-in-order

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

cts:search has its own ordering functionality, which you can trigger using functions like cts:index-order. fn:doc takes an array, and will return them in database order. Neither of them sounds like what you are trying to achieve.

I would suggest explicitly iterating over the uris, and fetching the uris one by one. You could use ! operator for this, for instance:

("/doc1", "/doc2", "/doc3") ! doc(.)

HTH!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...