[英]How to use the NEST “.net client” for Elasticsearch to paginate through all the records?
我正在尝试使用Elasticsearch NEST的C# .net 客户端对所有可用记录进行分页。
我想一次从服务器 5000 获取所有 ID 的列表。 所以我得到的第一个请求是 0-5000,下一个请求是 5001-10000,然后是 10001-15000....
似乎我应该使用search_after API 来获取记录,但对如何检索数据感到困惑。
这是我尝试做的事情,但我觉得我不明白我在做什么以及如何提出多个请求。
var products = await elasticClient.SearchAsync<Product>(x =>
x.Source(s => s.Includes(se => se.Field(sef => sef.Id))) // all I need back is the "id" field
.Sort(srt => srt.Ascending(p => p.Id)) // we can sort the ids
.SearchAfter(5000, "get list of ids??"); // I have no idea what parameters to provide this method!
);
如何使用 .net 库一次遍历所有可用的 ID“5000”ID?
用 pageNumber 参数试试这个:
var products = await elasticClient.SearchAsync<Product>(x =>
x.Source(s => s.Includes(se => se.Field(sef => sef.Id)))
.From(5000*(pageNumber-1))
.Size(5000)
.Sort(srt => srt.Ascending(p => p.Id))
);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.