I have a XML document like this.
<Authors>
<Author>
<name>R.N Tagore</name>
<book>Gitanjli</book>
</Author>
<Author>
<name>Premchand</name>
<book>Panch Parameshvar</book>
</Author>
<Author>
<name>H.R Bacchan</name>
<book>Madhushala</book>
</Author>
<Author>
<name>Premchand</name>
<book>Gaban</book>
</Author>
<Author>
<name>Premchand</name>
<book>Nirmala</book>
</Author>
<Author>
<name>Premchand</name>
<book>Nirmala</book>
</Author>
</Authors>
From the above XML I need distinct list of author's name.
For this I can write a query like ,
fn:distinct-values(cts:search(fn:doc()//pa:Author/pa:name,cts:and-query(())))
What the above code will do is, It will get result of Authors name and then fn:distinct-values() function will filter distinct Author name from that result set. For the current scenario it will work fine because data in XML only 6, But when data is very high let say 50 lac's
cts:search(fn:doc()//pa:Author/pa:name,cts:and-query(()))
the above portion of query will give XDMP-EXPNTREECACHEFULL Exception because we are trying to cache 50 lac's element in memory.
So need your help to get only distinct author name by using cts:search or search:search API. I don't want to first get a result set and then extract distinct record from that result set by using fn:distinct-values().
Thanks,