How to init a scroll without returning the result in Elasticsearch.Net 5?

215 views Asked by At

Since SearchType.Scan has been removed in Elasticsearch.Net 5 I can't get my head around how to init a scroll which just return the scrollId and not all documents also. Any advice?

1

There are 1 answers

0
Russ Cam On

You just need to specify Scroll on the search request

var response = client.Search<Document>(s => s
    .MatchAll()
    .Scroll(TimeSpan.FromMinutes(1))
);

or

var request = new SearchRequest<Document>
{
    Query = new MatchAllQuery(),
    Scroll = TimeSpan.FromMinutes(1)
};

var response  = client.Search<Document>(request);

The response will contain the first set of scrolled documents and a scroll id to use to fetch the next set