# Using fluent lambda expressions with a scroll search request

**URL:** <https://discuss.elastic.co/t/using-fluent-lambda-expressions-with-a-scroll-search-request/382562>\
**Category:** Elasticsearch\
**Tags:** language-clients\
**Created:** [October 9, 2025, 2:58pm UTC](https://discuss.elastic.co/t/using-fluent-lambda-expressions-with-a-scroll-search-request/382562 "2025-10-09T14:58:04Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![TSlump](https://avatars.discourse-cdn.com/v4/letter/t/ac8455/32.png) [@TSlump](https://discuss.elastic.co/u/TSlump)\
**Post date:** [October 9, 2025, 2:58pm UTC](https://discuss.elastic.co/t/using-fluent-lambda-expressions-with-a-scroll-search-request/382562/1 "2025-10-09T14:58:04Z")

</div>

I’ve been unable to use fluent lambda expressions when searching with a scroll. I have the code working using direct creations of the request objects:

```auto
public async Task<List<int>> GetAllElasticIds()
{
   var ids = new List<int>();

    var searchResponse = await this.elasticsearchClient.SearchAsync<ElasticModel>(s => s
        .Index(“index1”)
        .Query(q => q
            .MatchAll(_ => { }))
        .Size(5)
        .Scroll(“1m”)
        .Source(new SourceConfig(new SourceFilter
        {
            Includes = "id"
        })));
    
    ids.AddRange(searchResponse.Documents.Select(d => d.Id));

    var scrollId = searchResponse.ScrollId;
    var docCount = searchResponse.Documents.Count;
    
    while (scrollId is not null && docCount != 0)
    {
        var scrollResponse = await this.elasticsearchClient.ScrollAsync<ElasticModel>(new ScrollRequest{ScrollId = scrollId, Scroll = ScrollTime});

        ids.AddRange(scrollResponse.Documents.Select(d => d.Id));
        
        scrollId = scrollResponse.ScrollId;
        docCount = scrollResponse.Documents.Count;
    }
    
    if (scrollId is not null)
    {
           var clearScrollResponse = await this.elasticsearchClient.ClearScrollAsync(new ClearScrollRequest {ScrollId = scrollId});
    }
}

```

Is there a way I can fluently create the SourceConfig / SourceFilter / ScrollRequest / ClearScrollRequest objects within the request ?

Elasticsearch package version: 8.18

---

<div class="post-metadata">

**Author:** ![flobernd](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/flobernd/32/124877_2.png) [@flobernd](https://discuss.elastic.co/u/flobernd)\
**Post date:** [October 10, 2025, 3:16pm UTC](https://discuss.elastic.co/t/using-fluent-lambda-expressions-with-a-scroll-search-request/382562/2 "2025-10-10T15:16:35Z")

</div>

@TSlump It should be possible when using client 8.19.x. I decided to backport all 9.0+ improvements to 8.19. This also includes a lot of usability fixes to the fluent syntax. Please carefully check the 9.0 breaking changes since they apply to 8.18 → 8.19 as well.

---

<div class="post-metadata">

**Author:** ![TSlump](https://avatars.discourse-cdn.com/v4/letter/t/ac8455/32.png) [@TSlump](https://discuss.elastic.co/u/TSlump)\
**Post date:** [October 10, 2025, 3:31pm UTC](https://discuss.elastic.co/t/using-fluent-lambda-expressions-with-a-scroll-search-request/382562/3 "2025-10-10T15:31:07Z")

</div>

Ah awesome, will use the 8.19 package instead then. Thank you !
