Reputation: 753
I'm fairly new to Aerospike. Been checking the API docs, but I'm having trouble getting a clear process. I'm using the Node Client.
I have records: Ex:
key: {ns:'cache', set:'fieldA', key:'1437777737287'}
value: [1,2,3,4,5,6,7,8,9]
I want to make a query that will fetch records with matching ns, set and keys from 1437777737277 to 1437777737297, for example.
What would be the best approach ?
Thanks
Upvotes: 2
Views: 486
Reputation: 7117
You should use batchGet to fetch a predefined range of keys, as log as the namespace and set are the same.
Upvotes: 1
Reputation: 9034
You can use a query with range filters:
var filter = aerospike.filter;
var query = client.query('cache', 'fieldA', {filters: [filter.range('id', 1437777737277, 1437777737297)]});
var queryStream = query.execute();
queryStream.on('data', function (rec) {
console.log(rec);
});
queryStream.on('error', function (err) {
console.log(err);
});
queryStream.on('end', function () {
console.log('the end')
});
Upvotes: 4