Not sure what language you work in, or if you still need an answer, but this is what I did to work with TOP X until the function is implemented.
I wanted to run a query and only grab the top 1 of the results without returning the entire collection. In the SDK, I found a feedOptions object that was able to select only the TOP X that I need.
Code:
.NET ( MSDN ):
var options = new FeedOptions { MaxItemCount = 1 }; var query = _documentclient.CreateDocumentQuery<MyObject>(this.MyObjects.SelfLink, "SELECT * FROM MyObject m WHERE m.Enabled = false", options).AsDocumentQuery(); var topItem = (await query.ExecuteNextAsync<MismatchedAnswer>()).FirstOrDefault();
Node.js ( GITHUB )
client.queryDocuments(collectionSelfLink, "SELECT * FROM MyObject m WHERE m.Enabled = false",{maxItemCount: 1}).nextItem(function(err, element){ console.log([err, firstItem]); })
source share