How to create a list of all the keys in a Couchbase cluster?

Does anyone know a way to extract all the keys?

I have 600 milion keys but I need to query the document one by one. How can I get this list?

If I run a query like:

SELECT META(`internal`).id FROM `internal` LIMIT 10 OFFSET 600000000

I always get timeouts, so, there is no way in which I can extract in small batches. It work corectly if the offset is small, but when we reach a few milions the couchbase become unresponsive.

Thank you,

Do In the batches as follows

CREATE PRIMARY INDEX.

dockey = ""

FOR 
    SELECT META().id FROM default WHERE META().id > $dockey LIMIT 10000;
    dockey = last dockey
   if resultCount < 10000
      then break
  fi
END of FOR

https://blog.couchbase.com/offset-keyset-pagination-n1ql-query-couchbase/