How do I set continuation tokens for Cosmos DB queries sent by document_client objects in Python?

后端 未结 3 1152
一个人的身影
一个人的身影 2021-01-26 23:03

I have an API that retrieves documents based on keywords that appear in document fields. I would like to paginate results so that I can return documents to a client sending a re

3条回答
  •  后悔当初
    2021-01-26 23:47

    The way continuation token works is that when you query documents and there are more documents available matching that query, service returns you a marker (or a token) that you need to include in your next query. That will tell the service to fetch the documents from that marker and not the beginning.

    So in your code, the very 1st query will have no continuation parameter (or null). When you get the result, you should find if or not a token is returned from the service. If no token is returned that means there's no more data available. However if a token is returned, you should include that in your query options in the 2nd query.

提交回复
热议问题