Trevor Track
Trevor Track

Reputation: 196

How to delete multiple records in Aerospike given multiple keys through a single AQL query?

I have a list of Aerospike keys with me. I need to delete all the records associated with these keys using AQL.

I am aware of the delete query for a single key. Like this:

DELETE FROM <ns>[.<set>] WHERE PK=<key>

However, I would like to delete them all using AQL in a single query. Is there any such query to delete in bulk?

Upvotes: 2

Views: 2228

Answers (1)

pgupta
pgupta

Reputation: 5415

I don't think you can do that. How are these keys generated? If there is a pattern to it, then you can write a short python script to generate a text file, which has the delete commands. For example:

File: mydelete.txt

DELETE FROM ns1.set1 WHERE PK = 'k1'
DELETE FROM ns1.set1 WHERE PK = 'k2'
etc..

Then, in AQL, use the RUN command.

aql> RUN 'mydelete.txt'

However, if you want to delete all the records in a set, you can use TRUNCATE in AQL.

Upvotes: 4

Related Questions