Hi list, I have some days with a problem and I hope anybody can help me. I have developed an extension module to search documents in an eXist collection using Lucene. The module works fine and returns a Sequence with all the documents matching a query sorted by the score of Lucene, but when I call the function of the module in an XQuery script, the documents don't appear in the same order.
I have this function which take an array with the document's names as argument and returns a NodeSet with this documents from eXist collection: protected static NodeSet getDocuments(String[] cgDocNames, DBBroker broker) throws XPathException { //Creamos una Secuencia para almacenar los resultados ExtArrayNodeSet documents = new ExtArrayNodeSet(cgDocNames.length, 1); //obtiene la coleccion de reportes Collection cdData = broker.getCollection(XmldbURI.create(JReportsModule.REPORTSDIRECTORY_DATA_COLLECTION)); //itera sobre los nombres de reportes for(int i = 0; i < cgDocNames.length; i ++) { //System.out.println(cgDocNames[i]); DocumentImpl cgDoc = cdData.getDocument(broker, XmldbURI.create(cgDocNames[i].substring(cgDocNames[i].indexOf(" ")+1,cgDocNames[i].length()))); if(cgDoc != null){ //aƱade el reporte a la secuencia de resultados documents.add(new NodeProxy(cgDoc)); } } documents.sort(true); return (NodeSet) documents; } In the eval function of the extension module I call this getDocuments function and that's the Sequence eval returns. Until this moment it seems the documents are in the correct order, but when I call the function of the extension module in an XQuery script the documents are returned in unorder. Is the description clear? because my english is not very good. Thanks