# Composite keys for Aerospike

**URL:** <https://discuss.aerospike.com/t/composite-keys-for-aerospike/7207>\
**Category:** General Discussion\
**Tags:** query, index\
**Created:** [March 11, 2020, 6:38am UTC](https://discuss.aerospike.com/t/composite-keys-for-aerospike/7207 "2020-03-11T06:38:45Z")\
**Posts on this page:** 1\
**Showing post:** 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:** [March 11, 2020, 1:33pm UTC](https://discuss.aerospike.com/t/composite-keys-for-aerospike/7207/3 "2020-03-11T13:33:49Z")

</div>

Trust what Vikrant is looking for is if you have records such as: Last Name | State | Shoe Size as the 3 bins in the data, and record’s primary key is say some “userid”, Vikrant wants to query a specific lastname+state combination i.e. fetch all Gupta in CA. Building such composite keys out of data in bins is not possible in Aerospike. While the query is possible using Secondary Indexes and Predicate Filtering - this concept of “Composite Key” is not available - no APIs hence. What Albot is suggesting is using the primary key as: “Gupta:CA:userid” to store the record instead of “userid” and then use logic in application to batch read the records that are of interest. In this case, somewhere you will keep a count of total userids for “Gupta:CA” so you can build the list of keys to retrieve via batch read. i.e. [Gupta:CA:0, Gupta:CA:1, … Gupta:CA:xxx (last)]

---

_[View the full topic](https://discuss.aerospike.com/t/composite-keys-for-aerospike/7207)._
