How do I retrieve the meta-data of a record from AQL?

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.

Summary

To retrieve the meta-data of a record which are digest, generation and TTL, use the RECORD_PRINT_METADATA setting in AQL. Note that this setting is valid only in JSON view mode.

Example

aql> SET OUTPUT JSON
aql> SET RECORD_PRINT_METADATA true
aql> insert into test.testset (PK,bin) values (200,20000)
OK, 1 record affected.

aql> select * from test.testset where PK=200
[
  {
    "digest": "AAAAAAAAAAAAAAAAAAAAAAAAAAA=",
    "ttl": 2592000,
    "gen": 1,
    "bins": {
      "bin": 20000
    }
  }
]

Documentation reference for more AQL settings:

To know more about data-model in Aerospike: http://www.aerospike.com/docs/architecture/data-model.html

For others’ reference. To revert back to tabular view:

SET OUTPUT TABLE

Also, it appears that AQL displays digest/ttl/generation data in tabular view as well, at least as of 3.9.x:

+--------------+-------------+--------------------------------+------------+-------+
| a            | maxNumLists | {digest}                       | {ttl}      | {gen} |
+--------------+-------------+--------------------------------+------------+-------+
| 10           | 2           | "Mj6QJaUNFYKk+urOhhaHMuiwqu0=" | 4294967295 | 1     |
+--------------+-------------+--------------------------------+------------+-------+