[英]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.