I'm trying to understand why an elasticsearch.net NEST scroll call keeps returning the same results. I have an outer loop in my C# application that tracks the current page and it's passed in along with the batch size. I've simplified the code:
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++;
}
In the above call the list of ids are ids of nested elements in a one to many relationship with the objects they're contained within. That's why I want to use scroll as I don't know how many Invoice objects will be returned. Every time this is called currentPage is incremented by 1. I had assumed that the next batch from the scroll would be returned.
I think I'm doing something wrong as I'm looking at this as more of a paging flow.