IN query on PK



How to perform IN queries in aerospike. Do we need an UDF for this? Something like this: Select * from ns.set where PK in (1,2,3)


In Ver 3.12.1+, you can run such queries if you store your Primary Key in a bin and then run predicate filtering on that bin. See

Aerospike by default does not store the PK in its raw string or numeric form as you assign it. It stores a RIPEMD160 hash of the PK+Set name.


In AQL, you cannot perform this kind query. But in aerospike client, for example python, you can use, “get_many” api to get multiple keys. In java api, you also can use batch policy to do that such as Record[] get(BatchPolicy policy, Key[] keys, String... binNames) if you want to store PK in aerospike, you need to set write policy when data insert. in java, it is “sendkey” field


good point, the actual question though presented as a where query on PK really boils down to batch read! I missed that.