How to get Key from Query Records

I am only getting a hashed value of Key, and not the actual key. How to get the key?

	stmt := as.NewStatement("test", "new_table")

	f := as.NewRangeFilter("rs", 200, 210)

	stmt.SetFilter(f)
	r, _ := client.Query(readPolicy, stmt)
r, _ := client.Query(readPolicy, stmt)
	for i := range r.Results() {
		fmt.Println(i.Record.Key.String())
                fmt.Println(i.Record.Key.Digest())
	}

Output

test:new_table::04 8e 14 8a 4d 94 71 15 fc b6 a6 30 35 24 fb 85 76 51 ea 6c 
[4 142 20 138 77 148 113 21 252 182 166 48 53 36 251 133 118 81 234 108]

You answered yourself, I believe (see below). Using the SEND_KEY policy to true on both writes and reads does the trick. The comes with the cost of storing the Key as a hidden bin with the record.

That said, remember that you can access records directly with the digest, even if you don’t have the userKey. So even if you don’t know the key, and get back a bunch of digests from a scan/query, you can then get or batch-read those records by the digests.

© 2015 Copyright Aerospike, Inc. | All rights reserved. Creators of the Aerospike Database.