Azure Cosmos Db,在行后选择?
我正在尝试在x行之后选择一些行,例如:Azure Cosmos Db,在行后选择?,azure,azure-cosmosdb,Azure,Azure Cosmosdb,我正在尝试在x行之后选择一些行,例如: SELECT * from collection WHERE ROWNUM >= 235 and ROWNUM <= 250 从集合中选择*,其中ROWNUM>=235和ROWNUM 例如,我在Azure中有1000000条记录。我想查询行 500000至500010。我无法从集合中选择*,其中ROWNUM>=500000和ROWNUM您是什么意思看起来ROWNUM没有在azure cosmos db中解析?有错误吗?还有更多详细信息吗?当我
SELECT * from collection WHERE ROWNUM >= 235 and ROWNUM <= 250
从集合中选择*,其中ROWNUM>=235和ROWNUM
例如,我在Azure中有1000000条记录。我想查询行
500000至500010。我无法从集合中选择*,其中ROWNUM>=500000和ROWNUM您是什么意思看起来ROWNUM没有在azure cosmos db中解析?有错误吗?还有更多详细信息吗?当我进行SQL查询时,我得到一个错误,说rownum不存在。一般来说,continuation标记与maxItemCount参数结合使用。你的意思是你的续写令牌在50页后不起作用?您的页面大小是多少?您有多少项?例如,我在Azure中有1000000条记录。我想查询500000到500010行。我无法从ROWNUM>=500000且ROWNUM Hi的集合中选择*,是否有任何进展?我的答案对你有帮助吗?嗯,这仍然意味着在到达我想看的页面之前,我必须浏览所有页面。有没有一种方法可以使用过滤器跳转到该页面?比如“select*where c.tags.mytag=true”,或者如果我按索引值排序,然后跳到500000到500010?不断地向数据库请求条目以达到我想要的记录似乎效率低下。
using JayGongDocumentDB.pojo;
using Microsoft.Azure.Documents.Client;
using Microsoft.Azure.Documents.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace JayGongDocumentDB.module
{
class QuerySample1
{
public static async void QueryPageByPage()
{
// Number of documents per page
const int PAGE_SIZE = 2;
int currentPageNumber = 1;
int documentNumber = 1;
// Continuation token for subsequent queries (NULL for the very first request/page)
string continuationToken = null;
do
{
Console.WriteLine($"----- PAGE {currentPageNumber} -----");
// Loads ALL documents for the current page
KeyValuePair<string, IEnumerable<Student>> currentPage = await QueryDocumentsByPage(currentPageNumber, PAGE_SIZE, continuationToken);
foreach (Student student in currentPage.Value)
{
Console.WriteLine($"[{documentNumber}] {student.Name}");
documentNumber++;
}
// Ensure the continuation token is kept for the next page query execution
continuationToken = currentPage.Key;
currentPageNumber++;
} while (continuationToken != null);
Console.WriteLine("\n--- END: Finished Querying ALL Dcuments ---");
}
public static async Task<KeyValuePair<string, IEnumerable<Student>>> QueryDocumentsByPage(int pageNumber, int pageSize, string continuationToken)
{
DocumentClient documentClient = new DocumentClient(new Uri("https://***.documents.azure.com:443/"), "***");
var feedOptions = new FeedOptions
{
MaxItemCount = pageSize,
EnableCrossPartitionQuery = true,
// IMPORTANT: Set the continuation token (NULL for the first ever request/page)
RequestContinuation = continuationToken
};
IQueryable<Student> filter = documentClient.CreateDocumentQuery<Student>("dbs/db/colls/item", feedOptions);
IDocumentQuery<Student> query = filter.AsDocumentQuery();
FeedResponse<Student> feedRespose = await query.ExecuteNextAsync<Student>();
List<Student> documents = new List<Student>();
foreach (Student t in feedRespose)
{
documents.Add(t);
}
// IMPORTANT: Ensure the continuation token is kept for the next requests
return new KeyValuePair<string, IEnumerable<Student>>(feedRespose.ResponseContinuation, documents);
}
}
}