I use the query below to retrieve various values from XML files stored in a collection in MarkLogic. The collection contains more than 40 thousand files.
When a query is executed, the results take a long time. Is there a better way to optimize the query below or any other use cases for this query without XPath.
XQUERY:
fn:distinct-values(fn:collection(collectionName)//caseml/case[@jur eq in]/@year)
XML input example:
<?xml version="1.0" encoding="UTF-8"?>
<caseml>
<case jur="in" series="mlj" volume="1" year="2016" startpage="129">
<p num="y" pnum="22">
<text>
In view of the aforesaid discussion, we find the writ petition completely devoid
of any merit and accordingly, we dismiss the same, leaving the parties to bear their
own costs.
</text>
</p>
</case>
</caseml>
The above XQuery works, but you need to get results faster.
source
share