How to Select First matching document by group by for more than 10000 records

I am using Collapse to get first element of group by with the search api. but it is working if my Limit+offset is less than 10000. for more than 10000 i am using the scroll api , collpase is not working with scroll , what laternative i can use here . My code Snippet is

return await _elasticClient.SearchAsync(bd => (((input.Limit +input.Offset) > 0 && (input.Limit + input.Offset) < 10000)
? bd.From(offset).Size(limit).Collapse(x => x.Field(f => f.SnippetId))
: bd.Scroll(TimeSpan.FromMinutes(30)).Take(limit))
.Query(TDMSnippetTableSearchQuery(input, includeCompetitors)
));

Please help me to resolve this.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.