Get distinct result set in marklogic server

Gordi

New Member
I have a XML document like this.\[code\] <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>\[/code\]From the above XML I need distinct list of author's name.
For this I can write a query like ,\[code\]fn:distinct-values(cts:search(fn:doc()//pa:Author/pa:name,cts:and-query(())))\[/code\]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 \[code\]cts:search(fn:doc()//pa:Author/pa:name,cts:and-query(()))\[/code\]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,
 
Back
Top