【发布时间】:2021-07-15 23:54:16
【问题描述】:
我正在尝试使用C# .net client for Elasticsearch NEST 对所有可用记录进行分页。
我想一次从服务器 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?
【问题讨论】:
标签: c# .net elasticsearch nest elasticsearch-7