Search code examples
javaaerospikeaerospike-ce

How to get the primary key (PK) of a record in aerospike?


I want to get a specific record from a set in aerospike.

But when i execute the following query, i got no result:

select * from ctl.prodCache where PK='111222';

But when i execute the following query:

select * from ctl.prodCache;

It gives me all the records, but does not shows the primary key at all.

{ "edigest": "BE6ZxLRMKwnbmUqPTvsmcIAgVv8=", "set": "prodCache", "ttl": 54, "gen": 1, "bins": { "C": "java.util.ArrayList", "V": "00 10 70 61 79 74 6D 6D 61 2E 64 6F 6D 61 69 6E 2E 43 " } }

Any suggestions? Please help.


Solution

  • First execute the following commands from AQL:

    SET KEY_SEND TRUE
    

    and then insert the data in specific sets.

    After that, execute the select query.

    The PK will be shown only for the inserts for which the insertions were done setting the KEY_SEND to true.