function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Steven NsubugaSteven Nsubuga 

Elastic Search scroll_id

I need to get data from a web service that only returns 10 records at a time.  Even when I set the size parameter to a higher number, I still only get 10 records. The web service owners tell me I must use the scroll_id from elastic search. 
Below is my code
 
HttpRequest req = new HttpRequest();
            req.setEndpoint('https://aa.bb.org/bdo/2.3.0/-eligible-for-af');
            req.setMethod('POST');
            req.setHeader('Authorization', 'Bearer eeee-gggg-hhhh-ijkl');
            System.JSONGenerator gen = System.JSON.createGenerator(true);
            gen.writeStartObject();
            gen.writeFieldName('query');
            gen.writeStartObject();
            gen.writeFieldName('match_all');
            gen.writeStartObject();
            gen.writeEndObject();
            gen.writeNumberField('size', 500);
            gen.writeEndObject();
            String pretty = gen.getAsString();
            req.setBody(pretty);
            Http httpReq = new Http();
            HttpResponse res = httpReq.send(req);
            json = res.getBody();
AfJSON2Apex afWithFinance = AfJSON2Apex.parse(json);

The last class is used to parse the json and in there I am able to access the scroll id parameter.
I need help setting up the code to run continuously/recursively until all the records are returned. Anyone willing to help me on this?  I do not want to keep