Hi, Julia: I'm able to reproduce the issue. It appears that the collection is not being set for any QBE (independent of the ordering) and that it's a bug in the REST API.
Until the bug is fixed, you should either use QBE with enough criteria that the collection is unnecessary or to use the Query Builder with the collection instead of QBE. Thanks for identifying the issue, Erik Hennum ________________________________________ From: [email protected] [[email protected]] on behalf of Julia Egoshina [[email protected]] Sent: Tuesday, April 14, 2015 3:33 AM To: [email protected] Cc: Maxim Trushin Subject: [MarkLogic Dev General] cannot fetch ordered documents from specified collection using nodeJS Hi, I’ve got a problem with querying data using QBE from nodeJS. The following code works fine. It returns data that fits my example from the specified collection. var query = client.qb.where( client.qb.byExample( { "isin": params.isin } ) ); client.queryCollection( config.MARKLOGIC_STATIC_COL_NAME, query ).result( function (docs) { if (docs.length >= 1) { queryResults[queryResults.length] = docs[0]; FetchLastPrice(docs[0].sedol, 1); } else { LogWrite('Unable to find static document for isin "' + params.isin + '"'); next(errResult); } }, function (err) { LogWrite(JSON.stringify(err, null, 4)); next(errResult); } ); Once I add an orderBy statement (highlighted) the REST service starts returning documents that fit my example not only from the specified collection but from all collections in my database. var query = client.qb.where( client.qb.byExample( { "isin": params.isin } ) ).orderBy(client.qb.sort('validStart', 'descending')); client.queryCollection( config.MARKLOGIC_STATIC_COL_NAME, query ).result( function (docs) { if (docs.length >= 1) { queryResults[queryResults.length] = docs[0]; FetchLastPrice(docs[0].sedol, 1); } else { LogWrite('Unable to find static document for isin "' + params.isin + '"'); next(errResult); } }, function (err) { LogWrite(JSON.stringify(err, null, 4)); next(errResult); } ); How can I fix it up? _______________________________________________ General mailing list [email protected] Manage your subscription at: http://developer.marklogic.com/mailman/listinfo/general _______________________________________________ General mailing list [email protected] Manage your subscription at: http://developer.marklogic.com/mailman/listinfo/general
