# IN query on PK

**URL:** https://discuss.aerospike.com/t/in-query-on-pk/4158
**Category:** User Defined Functions (UDF)
**Tags:** query, udf
**Created:** [May 15, 2017, 10:06am UTC](https://discuss.aerospike.com/t/in-query-on-pk/4158 "2017-05-15T10:06:23Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![sandeep](https://avatars.discourse-cdn.com/v4/letter/s/ecccb3/32.png) [@sandeep](https://discuss.aerospike.com/u/sandeep)
#### Post date: [May 15, 2017, 10:06am UTC](https://discuss.aerospike.com/t/in-query-on-pk/4158/1 "2017-05-15T10:06:23Z")

</div>

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)

---

<div class="post-metadata">

### Author: ![pgupta](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.aerospike.com/pgupta/32/2351_2.png) [@pgupta](https://discuss.aerospike.com/u/pgupta)
#### Post date: [May 15, 2017, 4:26pm UTC](https://discuss.aerospike.com/t/in-query-on-pk/4158/2 "2017-05-15T16:26:29Z")

</div>

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 [http://www.aerospike.com/docs/guide/predicate.html](http://www.aerospike.com/docs/guide/predicate.html)

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.

---

<div class="post-metadata">

### Author: ![RockyTu](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.aerospike.com/rockytu/32/785_2.png) [@RockyTu](https://discuss.aerospike.com/u/RockyTu)
#### Post date: [May 17, 2017, 1:46am UTC](https://discuss.aerospike.com/t/in-query-on-pk/4158/3 "2017-05-17T01:46:32Z")

</div>

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. [https://pythonhosted.org/aerospike/client.html#aerospike.Client.get\_many](https://pythonhosted.org/aerospike/client.html#aerospike.Client.get_many) 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

---

<div class="post-metadata">

### Author: ![pgupta](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.aerospike.com/pgupta/32/2351_2.png) [@pgupta](https://discuss.aerospike.com/u/pgupta)
#### Post date: [May 18, 2017, 2:58pm UTC](https://discuss.aerospike.com/t/in-query-on-pk/4158/4 "2017-05-18T14:58:33Z")

</div>

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