0
我想了解爲什麼elasticsearch.net NEST滾動調用不斷返回相同的結果。我在我的C#應用程序中有一個外循環,用於跟蹤當前頁面,並將其與批量大小一起傳入。我已經簡化了代碼:Elasticsearch.net - NEST滾動不斷返回相同的結果
List<int> ids = GetIds();
int count = _batchSize;
int currentPage = 0;
while (count == _batchSize)
{
var results = Execute(client => client.Search<Invoice>(s => s
.Index(indexName)
.Query(q => q
.Terms(n => n
.Field(f => f.Items.FirstOrDefault().MyInformation.FirstOrDefault().ItemID)
.Terms(ids)))
.Size(batchSize)
.From(currentPage * batchSize)
.Scroll("1m")
));
DoSomethingWithResults();
count = results.Count();
currentPage++;
}
在上面的調用ID列表是在一個嵌套的元素與他們在其中所包含的對象多關係的IDS。這就是爲什麼我想使用滾動,因爲我不知道將返回多少個發票對象。每次調用currentPage時,都會加1。我假設將返回滾動中的下一批。
我想我做錯了什麼,因爲我把它當作更多的尋呼流。
再次感謝拉斯! 我沒有注意到第一次和後來的檢索使用不同的呼叫類型。 現在一切正在按計劃進行,我很興奮! – CorribView
真棒聽! –