How can I get more than 5000 keys in one batch call?


KazuhideKin wrote on Wed Apr 02, 2014 11:53 pm Hi,

How can I get more than 5000 keys in one batch call? An exception occured while trying to get more than 5000 keys.

Exception in thread “main” com.aerospike.client.AerospikeException: Error Code 4: Parameter error at com.aerospike.client.command.BatchCommandGet.parseRecordResults( at com.aerospike.client.command.MultiCommand.parseResult( at com.aerospike.client.command.SyncCommand.execute( at com.aerospike.client.command.BatchExecutor$ at java.util.concurrent.ThreadPoolExecutor.runWorker( at java.util.concurrent.ThreadPoolExecutor$ at

Here is my sample code:

int size = 5001;

AerospikeClient cc = new AerospikeClient("localhost", 3000);

WritePolicy wp = new WritePolicy();
wp.expiration = 0;
Key[] keys = new Key[size];
for( int i = 0; i < size; i++){
  String skey = String.format("mykey%06d", i);
  keys[i] = new Key("test","myset",skey );
  Bin bin = new Bin("mybin","value");
  cc.put( wp, keys[i], bin);

Policy pc = new Policy();
Record[] rc = cc.get( pc, keys);


This is something configured in the server configuration file (/etc/aerospike/aerospike.conf). It defaults to 5,000. What you will need to do is put a variable in the "service" stanza called “batch-max-requests” to a higher value like 10,000 like this:

Select allservice {
    batch-max-requests 10000