List Keys : List keys in a ns.set

The Aerospike Knowledge Base has moved to https://support.aerospike.com. Content on https://discuss.aerospike.com is being migrated to either https://support.aerospike.com or https://docs.aerospike.com. Maintenance on articles stored in this repository ceased on December 31st 2022 and this article may be stale. If you have any questions, please do not hesitate to raise a case via https://support.aerospike.com.

Question:

We understand that in Aerospike, a “key” consists of a namespace,set,key. And using aql, we can show every records in a ns.set; however it does not show the key of each record. Is there a way to list the keys in a ns.set?

Resolution:

There is a way to list the keys in a ns.set, you can use AS_POLICY_KEY_SEND, If you want keys to be returned when scanning or querying, the keys must be stored on the server. This policy causes a write operation to store the key. Once a key is stored, the server will keep it – there is no need to use this policy on subsequent updates of the record.

More information can be found: http://www.aerospike.com/apidocs/c/db/d65/group__client__policies.html#ggaa9c8a79b2ab9d3812876c3ec5d1d50ecaababc37bcffeb6ac44a51336a28e3ef1