12

I am trying to query using aql (Aerospike Query Language) in aerospike set.
Suppose there are 1000 records and I want to read any 10 records. Usually I would query something like :

select * from test.demo limit 10;

How do I query the same using aql ?

holmes840
  • 1,063
  • 2
  • 11
  • 24

2 Answers2

5

At the moment you cannot do that in aql, but you can use the BETWEEN predicate to define a range to the query.

When you use the C-client (or one of the language clients that wrap around it) a scan (as_scan_foreach) can be limited by setting the percentage field of the as_scan struct.

Ronen Botzer
  • 6,951
  • 22
  • 41
  • This is such a basic requirement, 4 years later they still don't have this in their AQL CLI. – Dojo Aug 11 '23 at 06:27
1

Here is an example of 'scan' in Java.

    **this.client.scanAll(scanPolicy, "test", "demo", new ScanCallback() {

        @Override
        public void scanCallback(Key key, Record record) throws AerospikeException {
            System.out.println("Record: " + record);

        }
    });**

That there is no order implied in a 'scan', records are returned to your application in the order they are received from the nodes in the cluster.

Helipilot50
  • 227
  • 1
  • 1