Regex Predicate not returning all matches

test code adds 10000 records, containing value which is set up as secondary index - values are “identifier1” through “identifier10000”:

for (int i = 0; i < entriesToProcess; i++) {

			Sentence sentence = this.setUpSentenceGranule(i);

			SerializedInformationGranule serializedInformationGranule = sentence
					.serialize(":test2:" + PersistenceManager.getHighLevelGranuleTablePrefix(), true, 500);

			byte[] sentenceAsByteArray = serializedInformationGranule.getInformationGranuleByteBuffer().array();

			Key key = new Key(this.getNamespace(), ":test2:" + PersistenceManager.getHighLevelGranuleTablePrefix(), i);

			Bin byteArraybin = new Bin(null, sentenceAsByteArray);

			Bin secIdxOneBin = new Bin("idHLGT", sentence.getIdentifier());

			Bin secIdxTwoBin = new Bin("idNEMS", sentence.getValue());

			WritePolicy writePolicy = new WritePolicy();

			writePolicy.sendKey = true;

			this.getClient().put(writePolicy, key, byteArraybin, secIdxOneBin, secIdxTwoBin);


getting each of these records then shows that they were all created correctly and can all be retrieved with a primary key get.

Executing a query using a regex ^identifier12 returns only 37 records - there are actually 109 records that begin with identifier12

recordSet = client.query(queryPolicy, stmt);

		while (recordSet.iterator().hasNext()) {

			KeyRecord keyRecord = recordSet.iterator().next();

			byte[] receivedAsByteArray = (byte[]) keyRecord.record.getValue("");

			InformationGranule informationGranule = null;

			informationGranule = this.getInformationGranuleTyped(receivedAsByteArray, informationGranule);


			System.out.println("counter: " + counter + " information granule value: " + informationGranule.getValue());



Executing a query using a regex ^identifier1 returns only 370 records - there are 10000 records with this value

The strange thing is that multiples of 37 are being returned!

I have tried this with version 4.0.0 and version 4.0.7

com.aerospike aerospike-client ${aerospike.version}

My apologies (profuse!). This does work. Might be useful for future reference for others.

I changed this:

while (recordSet.iterator().hasNext()) {

		KeyRecord keyRecord = recordSet.iterator().next();

to this:

Iterator iterator2 = recordSet.iterator();

		while (iterator2.hasNext()) {

			try {

				KeyRecord keyRecord =;

so should not repeatedly call recordSet.iterator()

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

© 2015 Copyright Aerospike, Inc. | All rights reserved. Creators of the Aerospike Database.