When i am using a cts:search in XQuery i can sort quite easily by accessing the elements of the document.
cts:search(
fn:doc(),
cts:directory-query("/textdocuments/"),
cts:index-order(cts:element-reference(xs:QName("title")), "ascending")
)
The issue is that the value i want to use for sorting is contained in another document and the one in the found document is only a reference. E.g. The title hast to be translated, the translation is stored in a separate document and i want to sort after the translation. In SQL the solution would be to perform an inner join and then sort after the joined value. Is a similar solution possible?
I already tried using the Order part of a FLWOR expression and while this is working it is not optimal in performance since it requires loading all documents while i only want to load the first 20.