How to fetch more than 100 records from azure cosmos db using query How to fetch more than 100 records from azure cosmos db using query azure azure

How to fetch more than 100 records from azure cosmos db using query


I am writing a stored procedure and using a select query to fetch the record.

SELECT * FROM activities a

I am getting only 100 records though there are more than 500 records.

The default value of FeedOptions pageSize property for queryDocuments is 100, which might be the cause of the issue. Please try to set the value to -1. The following stored procedure works fine on my side, please refer to it.

function getall(){ var context = getContext();  var response = context.getResponse();  var collection = context.getCollection();  var collectionLink = collection.getSelfLink();  var filterQuery = 'SELECT * FROM c';  collection.queryDocuments(collectionLink, filterQuery, {pageSize:-1 },    function(err, documents) {      response.setBody(response.getBody() + JSON.stringify(documents));    }  );}


If anyone hits this page, the answers above are obsolete.@azure/cosmos now has some options like below for those who are interested:

const usersQuery = {        query: "SELECT * FROM c where c.userId = 'someid'" +            " order by c.userId asc,  c.timestamp asc"    };const { resources: users } = await container.items                .query(usersQuery, { maxDegreeOfParallelism: 5,maxItemCount: 10000 }).fetchNext()

For reference, see here.