Reputation: 445
How do I include the PK when doing a AQL select?
Example:
SELECT * from test.users
Returns:
FirstName, LastName etc
What I really want to know is the PK or key so I can delete a row. How can I include the PK in a SELECT AQL statement.
Upvotes: 4
Views: 6947
Reputation: 119
To DELETE the data from the sets - To delete a record from the set, you could use scanAll API which iterates through all the records and delete. During scanCallback call it gets the digest key for each record and deletes. Here is the reference link
http://www.aerospike.com/community/labs/deleting_sets_and_data.html
Once we have extended functionality of retrieving primary index through AQL then you can retrieve primary index key which you have created but make sure you have stored key by calling sendKey attribute of WritePolicy class. SendKey sends user defined key in addition to hash digest on a record put. By default it's not sent.
Upvotes: 2
Reputation: 4328
Alternative solution
create extra bin to save primary key and index it. Then you can retrieve this primary key using AQL statement.
Upvotes: 1
Reputation: 3567
By default, Aerospike does not store the actual primary key in the database. It stores the 20-byte digest (hash of the key) by default. This will be a huge saving for the large keys. However, in the latest version, this can be changed by the put() operation to store the key also. But the AQL client is not enhanced yet to exploit this fact. I will file an internal ticket for this enhancement.
In the mean time...
Upvotes: 7