Record storage
For the complete documentation index see: llms.txt
All documentation pages available in markdown.
Record storage expressions read a record’s own data as typed values: its bins, its primary key, and whether a bin exists. Together with record metadata, they are the leaves of an expression tree — every other expression in this reference takes its operands from one of these, or from another expression built on them.
Use a typed reader as the operand of a comparison or logic filter, as the collection operand of a list, map, or HLL expression, as the string operand of a string expression, or as the root of a path filter over nested data.
A typed reader evaluates to unknown when the bin is absent or holds a different type; see Unknown results. The key readers follow the same rule, so read a key with the reader matching how it was written — key_int, key_str, or key_blob.
bin_type is the exception to the pattern. It evaluates to an integer code naming the bin’s data type rather than to the bin’s value, which makes it the way to branch on what a bin holds before reading it.
The Developer SDK’s AEL text syntax infers most of these types from paths and literals, so an explicit typed reader is rarely needed.
Each operation’s Example shows the code in nine tabs: Aerospike Expression Language (AEL) text on the Java SDK and Python SDK tabs, and the Exp builder on the other seven. See the AEL reference for AEL grammar.
Ops
bin_blob(name)Returns the bin named by name as a blob, or unknown if the bin does not exist or holds a different type.
| Name | Type | Description |
|---|---|---|
name | string literal | Name of the bin. |
blob Records where blob bin checksum matches a 3-byte prefix (example digest bytes).
String exp = "$.checksum:BLOB == x'010203'";exp = "$.checksum:BLOB == x'010203'"use aerospike::expressions::{blob_bin, blob_val, eq};
let exp = eq(blob_bin("checksum".into()), blob_val(vec![0x01, 0x02, 0x03]));Expression exp = Exp.Build( Exp.EQ(Exp.BlobBin("checksum"), Exp.Val(new byte[] { 0x01, 0x02, 0x03 })));// Requires: import as "github.com/aerospike/aerospike-client-go/v8"exp := as.ExpEq( as.ExpBlobBin("checksum"), as.ExpBlobVal([]byte{0x01, 0x02, 0x03}),)const exp = Aerospike.exp
const filterExp = exp.eq( exp.binBlob('checksum'), exp.bytes(Buffer.from([0x01, 0x02, 0x03])),)uint8_t chk[] = { 0x01, 0x02, 0x03 };as_exp_build(predexp, as_exp_cmp_eq( as_exp_bin_blob("checksum"), as_exp_bytes(chk, sizeof(chk))));Expression exp = Exp.build( Exp.eq( Exp.blobBin("checksum"), Exp.val(new byte[] { 0x01, 0x02, 0x03 })));from aerospike_helpers.expressions import BlobBin, Eq
exp = Eq(BlobBin("checksum"), bytearray([0x01, 0x02, 0x03])).compile()bin_exists(name)Returns true if the record has a bin named name, otherwise false.
| Name | Type | Description |
|---|---|---|
name | string literal | Name of the bin. |
boolean Filter to records that have a quantity bin (any type).
String exp = "$.quantity.exists()";exp = "$.quantity.exists()"use aerospike::expressions::bin_exists;
let exp = bin_exists("quantity".into());Expression exp = Exp.Build(Exp.BinExists("quantity"));// Requires: import as "github.com/aerospike/aerospike-client-go/v8"exp := as.ExpBinExists("quantity")const exp = Aerospike.exp
const filterExp = exp.binExists('quantity')as_exp_build(predexp, as_exp_bin_exists("quantity"));Expression exp = Exp.build(Exp.binExists("quantity"));from aerospike_helpers.expressions import BinExists
exp = BinExists("quantity").compile()bin_float(name)Returns the bin named by name as a float, or unknown if the bin does not exist or holds a different type.
| Name | Type | Description |
|---|---|---|
name | string literal | Name of the bin. |
float Records where float bin list_price is under 15 (bookstore-style pricing).
String exp = "$.list_price:FLOAT < 15.0";exp = "$.list_price:FLOAT < 15.0"use aerospike::expressions::{float_bin, float_val, lt};
let exp = lt(float_bin("list_price".into()), float_val(15.0));Expression exp = Exp.Build( Exp.LT(Exp.FloatBin("list_price"), Exp.Val(15.0)));// Requires: import as "github.com/aerospike/aerospike-client-go/v8"exp := as.ExpLess(as.ExpFloatBin("list_price"), as.ExpFloatVal(15.0))const exp = Aerospike.exp
const filterExp = exp.lt(exp.binFloat('list_price'), exp.float(15.0))as_exp_build(predexp, as_exp_cmp_lt(as_exp_bin_float("list_price"), as_exp_float(15.0)));Expression exp = Exp.build( Exp.lt(Exp.floatBin("list_price"), Exp.val(15.0)));from aerospike_helpers.expressions import FloatBin, LT
exp = LT(FloatBin("list_price"), 15.0).compile()bin_geo(name)Returns the bin named by name as a GeoJSON value, or unknown if the bin does not exist or holds a different type.
| Name | Type | Description |
|---|---|---|
name | string literal | Name of the bin. |
geojson Records whose GeoJSON bin region contains the given point (same pattern as cmp_geo).
String exp = "geoCompare(" + "geoJson('{\"type\":\"Point\",\"coordinates\":[-122.4,37.8]}'), $.region:GEO)";exp = ("geoCompare(" "geoJson('{\"type\":\"Point\",\"coordinates\":[-122.4,37.8]}'), $.region:GEO)")use aerospike::expressions::{geo_bin, geo_compare, geo_val};
let point = "{\"type\":\"Point\",\"coordinates\":[-122.4,37.8]}";let exp = geo_compare(geo_val(point.into()), geo_bin("region".into()));string point = "{\"type\":\"Point\",\"coordinates\":[-122.4,37.8]}";Expression exp = Exp.Build( Exp.GeoCompare(Exp.Geo(point), Exp.GeoBin("region")));// Requires: import as "github.com/aerospike/aerospike-client-go/v8"point := "{\"type\":\"Point\",\"coordinates\":[-122.4,37.8]}"exp := as.ExpGeoCompare(as.ExpGeoVal(point), as.ExpGeoBin("region"))const exp = Aerospike.exp
const filterExp = exp.cmpGeo( exp.geo(new Aerospike.GeoJSON({ type: 'Point', coordinates: [-122.4, 37.8] })), exp.binGeo('region'),)as_exp_build(predexp, as_exp_cmp_geo( as_exp_geo("{\"type\":\"Point\",\"coordinates\":[-122.4,37.8]}"), as_exp_bin_geo("region")));String point = "{\"type\":\"Point\",\"coordinates\":[-122.4,37.8]}";Expression exp = Exp.build( Exp.geoCompare(Exp.geo(point), Exp.geoBin("region")));import aerospikefrom aerospike_helpers.expressions import CmpGeo, GeoBin
point = aerospike.GeoJSON( '{"type":"Point","coordinates":[-122.4,37.8]}')exp = CmpGeo(point, GeoBin("region")).compile()bin_hll(name)Returns the bin named by name as an HLL, or unknown if the bin does not exist or holds a different type.
| Name | Type | Description |
|---|---|---|
name | string literal | Name of the bin. |
hll Records where HLL bin visitors has a non-zero estimated cardinality, using HLLExp.getCount on the typed HLL bin.
String exp = "$.visitors:HLL.hllCount() > 0";exp = "$.visitors:HLL.hllCount() > 0"use aerospike::expressions::hll as hll_exp;use aerospike::expressions::{gt, hll_bin, int_val};
let exp = gt(hll_exp::get_count(hll_bin("visitors".into())), int_val(0));Expression exp = Exp.Build( Exp.GT(HLLExp.GetCount(Exp.HLLBin("visitors")), Exp.Val(0)));// Requires: import as "github.com/aerospike/aerospike-client-go/v8"exp := as.ExpGreater( as.ExpHLLGetCount(as.ExpHLLBin("visitors")), as.ExpIntVal(0),)const exp = Aerospike.exp
const filterExp = exp.gt( exp.hll.getCount(exp.binHll('visitors')), exp.int(0),)as_exp_build(predexp, as_exp_cmp_gt( as_exp_hll_get_count(as_exp_bin_hll("visitors")), as_exp_int(0)));import com.aerospike.client.exp.HLLExp;
Expression exp = Exp.build( Exp.gt(HLLExp.getCount(Exp.hllBin("visitors")), Exp.val(0)));from aerospike_helpers.expressions import GT, HLLBinfrom aerospike_helpers.expressions.hll import HLLGetCount
exp = GT(HLLGetCount(HLLBin("visitors")), 0).compile()bin_int(name)Returns the bin named by name as an integer, or unknown if the bin does not exist or holds a different type.
| Name | Type | Description |
|---|---|---|
name | string literal | Name of the bin. |
integer Records where integer bin quantity is in stock (greater than zero).
String exp = "$.quantity:INT > 0";exp = "$.quantity:INT > 0"use aerospike::expressions::{gt, int_bin, int_val};
let exp = gt(int_bin("quantity".into()), int_val(0));Expression exp = Exp.Build( Exp.GT(Exp.IntBin("quantity"), Exp.Val(0)));// Requires: import as "github.com/aerospike/aerospike-client-go/v8"exp := as.ExpGreater(as.ExpIntBin("quantity"), as.ExpIntVal(0))const exp = Aerospike.exp
const filterExp = exp.gt(exp.binInt('quantity'), exp.int(0))as_exp_build(predexp, as_exp_cmp_gt(as_exp_bin_int("quantity"), as_exp_int(0)));Expression exp = Exp.build( Exp.gt(Exp.intBin("quantity"), Exp.val(0)));from aerospike_helpers.expressions import GT, IntBin
exp = GT(IntBin("quantity"), 0).compile()bin_list(name)Returns the bin named by name as a list, or unknown if the bin does not exist or holds a different type.
| Name | Type | Description |
|---|---|---|
name | string literal | Name of the bin. |
list Records where list bin tags is non-empty, using the list bin value with a list read expression (size).
String exp = "$.tags:LIST.count() > 0";exp = "$.tags:LIST.count() > 0"use aerospike::expressions::lists as list_exp;use aerospike::expressions::{gt, int_val, list_bin};
let exp = gt(list_exp::size(list_bin("tags".into()), &[]), int_val(0));Expression exp = Exp.Build( Exp.GT(ListExp.Size(Exp.ListBin("tags")), Exp.Val(0)));// Requires: import as "github.com/aerospike/aerospike-client-go/v8"exp := as.ExpGreater( as.ExpListSize(as.ExpListBin("tags")), as.ExpIntVal(0),)const exp = Aerospike.exp
const filterExp = exp.gt( exp.lists.size(exp.binList('tags')), exp.int(0),)as_exp_build(predexp, as_exp_cmp_gt( as_exp_list_size(NULL, as_exp_bin_list("tags")), as_exp_int(0)));import com.aerospike.client.exp.ListExp;
Expression exp = Exp.build( Exp.gt(ListExp.size(Exp.listBin("tags")), Exp.val(0)));from aerospike_helpers.expressions import GT, ListBinfrom aerospike_helpers.expressions.list import ListSize
exp = GT(ListSize(None, ListBin("tags")), 0).compile()bin_map(name)Returns the bin named by name as a map, or unknown if the bin does not exist or holds a different type.
| Name | Type | Description |
|---|---|---|
name | string literal | Name of the bin. |
map Records where map bin attrs has at least one entry, using MapExp.size on the typed map bin.
String exp = "$.attrs:MAP.count() > 0";exp = "$.attrs:MAP.count() > 0"use aerospike::expressions::maps as map_exp;use aerospike::expressions::{gt, int_val, map_bin};
let exp = gt(map_exp::size(map_bin("attrs".into()), &[]), int_val(0));Expression exp = Exp.Build( Exp.GT(MapExp.Size(Exp.MapBin("attrs")), Exp.Val(0)));// Requires: import as "github.com/aerospike/aerospike-client-go/v8"exp := as.ExpGreater( as.ExpMapSize(as.ExpMapBin("attrs")), as.ExpIntVal(0),)const exp = Aerospike.exp
const filterExp = exp.gt( exp.maps.size(exp.binMap('attrs')), exp.int(0),)as_exp_build(predexp, as_exp_cmp_gt( as_exp_map_size(NULL, as_exp_bin_map("attrs")), as_exp_int(0)));import com.aerospike.client.exp.MapExp;
Expression exp = Exp.build( Exp.gt(MapExp.size(Exp.mapBin("attrs")), Exp.val(0)));from aerospike_helpers.expressions import GT, MapBinfrom aerospike_helpers.expressions.map import MapSize
exp = GT(MapSize(None, MapBin("attrs")), 0).compile()bin_str(name)Returns the bin named by name as a string, or unknown if the bin does not exist or holds a different type.
| Name | Type | Description |
|---|---|---|
name | string literal | Name of the bin. |
string Records in the fiction category (string bin category).
String exp = "$.category:STRING == 'fiction'";exp = "$.category:STRING == 'fiction'"use aerospike::expressions::{eq, string_bin, string_val};
let exp = eq(string_bin("category".into()), string_val("fiction".into()));Expression exp = Exp.Build( Exp.EQ(Exp.StringBin("category"), Exp.Val("fiction")));// Requires: import as "github.com/aerospike/aerospike-client-go/v8"exp := as.ExpEq(as.ExpStringBin("category"), as.ExpStringVal("fiction"))const exp = Aerospike.exp
const filterExp = exp.eq(exp.binStr('category'), exp.str('fiction'))as_exp_build(predexp, as_exp_cmp_eq(as_exp_bin_str("category"), as_exp_str("fiction")));Expression exp = Exp.build( Exp.eq(Exp.stringBin("category"), Exp.val("fiction")));from aerospike_helpers.expressions import Eq, StrBin
exp = Eq(StrBin("category"), "fiction").compile()bin_type(name)Returns the data type of the bin named by name, as an integer code, or 0
if the bin does not exist.
Compare the result against your client’s bin-type constants rather than writing the number directly. The codes are:
| Bin data type | Code |
|---|---|
| Integer | 1 |
| Double | 2 |
| String | 3 |
| Blob | 4 |
| Boolean | 17 |
| HyperLogLog | 18 |
| Map | 19 |
| List | 20 |
| GeoJSON | 23 |
| Name | Type | Description |
|---|---|---|
name | string literal | Name of the bin. |
integer Filter to records whose sku bin is stored as a string.
String exp = "$.sku.type() == STRING";exp = "$.sku.type() == STRING"use aerospike::expressions::{bin_type, eq, int_val};use aerospike::ParticleType;
let exp = eq(bin_type("sku".into()), int_val(ParticleType::STRING as i64));Expression exp = Exp.Build( Exp.EQ(Exp.BinType("sku"), Exp.Val((long)ParticleType.STRING)));// Requires: import as "github.com/aerospike/aerospike-client-go/v8"// Requires: import particleType "github.com/aerospike/aerospike-client-go/v8/types/particle_type"exp := as.ExpEq(as.ExpBinType("sku"), as.ExpIntVal(particleType.STRING))const exp = Aerospike.exp
const filterExp = exp.eq(exp.binType('sku'), exp.int(3))as_exp_build(predexp, as_exp_cmp_eq(as_exp_bin_type("sku"), as_exp_int(AS_BYTES_STRING)));import com.aerospike.client.command.ParticleType;
Expression exp = Exp.build( Exp.eq(Exp.binType("sku"), Exp.val(ParticleType.STRING)));import aerospikefrom aerospike_helpers.expressions import BinType, Eq
exp = Eq(BinType("sku"), aerospike.AS_BYTES_STRING).compile()key_blob()Returns the record’s user key as a blob, or unknown if the record has no stored key or the key is a different type.
blob Records whose blob user key matches a short byte sequence (for example a binary id).
String exp = "$.key():BLOB == x'1020'";exp = "$.key():BLOB == x'1020'"use aerospike::expressions::{blob_val, eq, key, ExpType};
let exp = eq(key(ExpType::BLOB), blob_val(vec![0x10, 0x20]));Expression exp = Exp.Build( Exp.EQ(Exp.Key(Exp.Type.BLOB), Exp.Val(new byte[] { 0x10, 0x20 })));// Requires: import as "github.com/aerospike/aerospike-client-go/v8"exp := as.ExpEq( as.ExpKey(as.ExpTypeBLOB), as.ExpBlobVal([]byte{0x10, 0x20}),)const exp = Aerospike.exp
const filterExp = exp.eq( exp.keyBlob(), exp.bytes(Buffer.from([0x10, 0x20])),)uint8_t id[] = { 0x10, 0x20 };as_exp_build(predexp, as_exp_cmp_eq(as_exp_key_blob(), as_exp_bytes(id, sizeof(id))));Expression exp = Exp.build( Exp.eq(Exp.key(Exp.Type.BLOB), Exp.val(new byte[] { 0x10, 0x20 })));from aerospike_helpers.expressions import Eq, KeyBlob
exp = Eq(KeyBlob(), bytearray([0x10, 0x20])).compile()key_int()Returns the record’s user key as an integer, or unknown if the record has no stored key or the key is a different type.
integer Records whose integer user key is at least 1000 (same units as the key type).
String exp = "$.key():INT >= 1000";exp = "$.key():INT >= 1000"use aerospike::expressions::{ge, int_val, key, ExpType};
let exp = ge(key(ExpType::INT), int_val(1000));Expression exp = Exp.Build( Exp.GE(Exp.Key(Exp.Type.INT), Exp.Val(1000)));// Requires: import as "github.com/aerospike/aerospike-client-go/v8"exp := as.ExpGreaterEq(as.ExpKey(as.ExpTypeINT), as.ExpIntVal(1000))const exp = Aerospike.exp
const filterExp = exp.ge(exp.keyInt(), exp.int(1000))as_exp_build(predexp, as_exp_cmp_ge(as_exp_key_int(), as_exp_int(1000)));Expression exp = Exp.build( Exp.ge(Exp.key(Exp.Type.INT), Exp.val(1000)));from aerospike_helpers.expressions import GE, KeyInt
exp = GE(KeyInt(), 1000).compile()key_str()Returns the record’s user key as a string, or unknown if the record has no stored key or the key is a different type.
string Records whose string user key is order-42.
String exp = "$.key():STRING == 'order-42'";exp = "$.key():STRING == 'order-42'"use aerospike::expressions::{eq, key, string_val, ExpType};
let exp = eq(key(ExpType::STRING), string_val("order-42".into()));Expression exp = Exp.Build( Exp.EQ(Exp.Key(Exp.Type.STRING), Exp.Val("order-42")));// Requires: import as "github.com/aerospike/aerospike-client-go/v8"exp := as.ExpEq(as.ExpKey(as.ExpTypeSTRING), as.ExpStringVal("order-42"))const exp = Aerospike.exp
const filterExp = exp.eq(exp.keyStr(), exp.str('order-42'))as_exp_build(predexp, as_exp_cmp_eq(as_exp_key_str(), as_exp_str("order-42")));Expression exp = Exp.build( Exp.eq(Exp.key(Exp.Type.STRING), Exp.val("order-42")));from aerospike_helpers.expressions import Eq, KeyStr
exp = Eq(KeyStr(), "order-42").compile()