Use of the primary index

When writing to aerospike with “sendKey=true”, there will be a bin named “PK” in the record, is the primary index also on this bin? Based on the documentation, “The primary index is on the 20 byte hash called the digest of the specified primary key”. So it’s probably not on this bin. I tried to do a range query on a numeric PK, like this “select * from [ns].[set] where PK between 100 and 200” but got an error response “Unsupported command format with token - ‘between’”.
What will be a proper way to do range query on a numeric PK?

The key is stored on the record, but it isn’t a “bin”.

Currently the only way to do a range query on the keys would be to store the key in a bin. If you decide to do this, you probably shouldn’t use the key-send policy since it will result in duplicate data on the record.

That said, there will be a way to support such queries on the stored key in the near future (likely 5.2).

I see, looks like the only way for now is to store the key in a bin, and create a secondary index on it. Thanks!

If you do store your key in a bin, this key being unique to all records, your secondary index on that bin - which you will need to build to do the range query - will pretty much take up as much process RAM as your primary index. So do plan for that higher need for RAM. See https://www.aerospike.com/docs/operations/plan/capacity/index.html#capacity-planning-for-secondary-indexes for details and better estimate.