I am using .From() and .Size() methods to retrieve all documents from Elastic Search results.
Below is sample example -
Here's an example of using scroll with NEST and C#. Works with 5.x and 6.x
public IEnumerable GetAllDocumentsInIndex(string indexName, string scrollTimeout = "2m", int scrollSize = 1000) where T : class
{
ISearchResponse initialResponse = this.ElasticClient.Search
(scr => scr.Index(indexName)
.From(0)
.Take(scrollSize)
.MatchAll()
.Scroll(scrollTimeout));
List results = new List();
if (!initialResponse.IsValid || string.IsNullOrEmpty(initialResponse.ScrollId))
throw new Exception(initialResponse.ServerError.Error.Reason);
if (initialResponse.Documents.Any())
results.AddRange(initialResponse.Documents);
string scrollid = initialResponse.ScrollId;
bool isScrollSetHasData = true;
while (isScrollSetHasData)
{
ISearchResponse loopingResponse = this.ElasticClient.Scroll(scrollTimeout, scrollid);
if (loopingResponse.IsValid)
{
results.AddRange(loopingResponse.Documents);
scrollid = loopingResponse.ScrollId;
}
isScrollSetHasData = loopingResponse.Documents.Any();
}
this.ElasticClient.ClearScroll(new ClearScrollRequest(scrollid));
return results;
}
It's from: http://telegraphrepaircompany.com/elasticsearch-nest-scroll-api-c/