Scan and scroll in php land

Hello, Can anybody tell me how can I scroll through a large index to get all the documents out ordered by time stamp?
my parameters to initial search are :

`[

        'search_type' => 'scan',
        'scroll'      => '2m',
        'size'       => 100,
        'index'      => $index,
        'body'       => [
            'query'  => $query,
            'sort'   => [
               '@ts' => [
                    'order' => 'asc'
                ]
            ]
        ]
    ];`

but the documents comes out in random order.

Hi Tswider,

The scan/scroll API does not sort documents, it's meant to efficiently retrieve all the documents matching a query, so you won't be able to order the documents by the order field (as in your example)

Thank you @dakrone, so is there any way of doing what I was trying to do ? geting large number (milions) of docs in a given order ?