---
title: "Map bin operations"
description: "Reference for Aerospike map bin expressions, covering read and modify operations with multi-language code examples."
---

# Map bin operations

> For the complete documentation index see: [llms.txt](https://aerospike.com/docs/llms.txt)
> 
> All documentation pages available in markdown.

Aerospike **map bin** expressions read and modify map-type bins inside filter, operation, and projection pipelines. Use them with [comparison](https://aerospike.com/docs/develop/expressions/comparison) and [logic](https://aerospike.com/docs/develop/expressions/logic) expressions when you need a boolean filter, or compose them with [record storage](https://aerospike.com/docs/develop/expressions/storage) typed-bin readers (`bin_map`) when you need the map value first.

In each operation, the map operand (`map_bin_expr` in the argument tables) is any **map-valued expression**: not only a named map bin, but also the result of another expression that evaluates to a map. Map operations **compose** by passing those values as the map input—for example, taking the size of a map after a `put`. For nested collection data and path filters, see [Querying collection data types](https://aerospike.com/docs/develop/expressions/nesting) and [Path expressions](https://aerospike.com/docs/develop/expressions/path/).

This reference covers read operations (size, get-by-key, get-by-value, index and rank variants, ranges, and the `map_keys`/`map_values` extraction helpers) and modify operations (`put`, `put_items`, `increment`, `clear`, and `remove_by_*` variants). Map modify expressions evaluate on a **temporary** map value; they do not persist unless used in a write operation that stores the result. Map operations change the copy of the map bin in place.

#### Composing expressions

The [`map_put`](https://aerospike.com/docs/develop/expressions/map-bin#map_put) reference includes an example that wraps `MapExp.put` in `MapExp.size`—the same modify-then-read pattern described above. Many other modify operations show similar composition: their examples nest another map expression as the map operand (`map_bin_expr` in the arguments table).

#### Extraction helpers

The [`map_keys`](https://aerospike.com/docs/develop/expressions/map-bin#map_keys) and [`map_values`](https://aerospike.com/docs/develop/expressions/map-bin#map_values) expressions (server 8.1.2+) are on the `Exp` class, not `MapExp`. They take a single map-valued expression and return a list—no `context` or `return_type` parameter. Use them to convert a map to a list of its keys or values for further expression processing, for example with [`in_list`](https://aerospike.com/docs/develop/expressions/comparison#in_list).

## Modify

#### `map_clear`

```python
map_clear(context, bin)
```

Description: [Clear](https://aerospike.com/develop/data-types/collections/map/operations#clear) all elements in map bin.

Arguments: | Name | Type |
| --- | --- |
| `context` | `library_specific` |
| `bin` | `map_bin_expr` |

Returns: `map_bin`

Introduced: 5.2.0.4

Example: Hypothetical filter using an empty map after `map_clear`.

-   [Java](#tab-panel-1296)
-   [Python](#tab-panel-1297)
-   [C](#tab-panel-1298)
-   [Go](#tab-panel-1299)
-   [C#](#tab-panel-1300)
-   [Node.js](#tab-panel-1301)

```java
import com.aerospike.client.exp.Expression;

import com.aerospike.client.exp.Exp;

import com.aerospike.client.exp.MapExp;

Expression exp = Exp.build(Exp.eq(MapExp.size(MapExp.clear(Exp.mapBin("stock"))), Exp.val(0)));
```

```python
from aerospike_helpers.expressions import Eq, MapBin

from aerospike_helpers.expressions.map import MapClear, MapSize

exp = Eq(MapSize(None, MapClear(None, MapBin("stock"))), 0).compile()
```

```c
as_exp_build(predexp,

  as_exp_cmp_eq(

    as_exp_map_size(NULL, as_exp_map_clear(NULL, as_exp_bin_map("stock"))),

    as_exp_int(0)));
```

```go
// Requires: import as "github.com/aerospike/aerospike-client-go/v6"

_ = as.ExpEq(as.ExpMapSize(as.ExpMapClear(as.ExpMapBin("stock"))), as.ExpIntVal(0))
```

```csharp
Expression exp = Exp.Build(

  Exp.EQ(MapExp.Size(MapExp.Clear(Exp.MapBin("stock"))), Exp.Val(0)));
```

```javascript
const Aerospike = require('aerospike')

const exp = Aerospike.exp

const filterExp = exp.eq(exp.maps.size(exp.maps.clear(exp.binMap('stock'))), exp.int(0))
```

---

#### `map_increment`

```python
map_increment(context, policy, key, delta, bin)
```

Description: [Increment](https://aerospike.com/develop/data-types/collections/map/operations#increment) element at **key** by **delta**.

Arguments: | Name | Type |
| --- | --- |
| `context` | `library_specific` |
| `policy` | `library_specific` |
| `key` | `expr` |
| `delta` | `integer_expr` |
| `bin` | `map_bin_expr` |

Returns: `map_bin`

Introduced: 5.2.0.4

Example: Hypothetical filter using the value at `sku-a` after incrementing it by `5`.

-   [Java](#tab-panel-1302)
-   [Python](#tab-panel-1303)
-   [C](#tab-panel-1304)
-   [Go](#tab-panel-1305)
-   [C#](#tab-panel-1306)
-   [Node.js](#tab-panel-1307)

```java
import com.aerospike.client.cdt.MapPolicy;

import com.aerospike.client.cdt.MapReturnType;

import com.aerospike.client.exp.Expression;

import com.aerospike.client.exp.Exp;

import com.aerospike.client.exp.MapExp;

Expression exp = Exp.build(

    Exp.eq(

        MapExp.getByKey(

            MapReturnType.VALUE,

            Exp.Type.INT,

            Exp.val("sku-a"),

            MapExp.increment(MapPolicy.Default, Exp.val("sku-a"), Exp.val(5), Exp.mapBin("stock"))),

        Exp.val(100)));
```

```python
import aerospike

from aerospike_helpers.expressions import Eq, MapBin, ResultType

from aerospike_helpers.expressions.map import MapGetByKey, MapIncrement

exp = Eq(

    MapGetByKey(

        None,

        aerospike.MAP_RETURN_VALUE,

        ResultType.INTEGER,

        "sku-a",

        MapIncrement(None, None, "sku-a", 5, MapBin("stock")),

    ),

    100,

).compile()
```

```c
as_map_policy mp;

as_map_policy_init(&mp);

as_exp_build(predexp,

  as_exp_cmp_eq(

    as_exp_map_get_by_key(

      NULL,

      AS_MAP_RETURN_VALUE,

      AS_EXP_TYPE_INT,

      as_exp_str("sku-a"),

      as_exp_map_increment(NULL, &mp, as_exp_str("sku-a"), as_exp_int(5), as_exp_bin_map("stock"))),

    as_exp_int(100)));
```

```go
// Requires: import as "github.com/aerospike/aerospike-client-go/v6"

_ = as.ExpEq(

  as.ExpMapGetByKey(

    as.MapReturnType.VALUE,

    as.ExpTypeINT,

    as.ExpStringVal("sku-a"),

    as.ExpMapIncrement(

      as.DefaultMapPolicy(),

      as.ExpStringVal("sku-a"),

      as.ExpIntVal(5),

      as.ExpMapBin("stock"),

    ),

  ),

  as.ExpIntVal(100),

)
```

```csharp
Expression exp = Exp.Build(

  Exp.EQ(

    MapExp.GetByKey(

      MapReturnType.VALUE,

      Exp.Type.INT,

      Exp.Val("sku-a"),

      MapExp.Increment(MapPolicy.Default, Exp.Val("sku-a"), Exp.Val(5), Exp.MapBin("stock"))),

    Exp.Val(100)));
```

```javascript
const Aerospike = require('aerospike')

const exp = Aerospike.exp

const maps = Aerospike.maps

const filterExp = exp.eq(

  exp.maps.getByKey(

    exp.maps.increment(exp.binMap('stock'), exp.int(5), exp.str('sku-a'), null),

    exp.str('sku-a'),

    exp.type.INT,

    maps.returnType.VALUE,

  ),

  exp.int(100),

)
```

---

#### `map_put`

```python
map_put(context, policy, key, value, bin)
```

Description: Add `{key, value}` element to bin. `map_put` does not create a new bin if the specified bin does not exist, unlike the [`put`](https://aerospike.com/docs/develop/data-types/collections/map/operations#put) CDT Map operation, which does create a new bin if the specified bin does not exist.

Arguments: | Name | Type |
| --- | --- |
| `context` | `library_specific` |
| `policy` | `library_specific` |
| `key` | `expr` |
| `value` | `expr` |
| `bin` | `map_bin_expr` |

Returns: `map_bin`

Introduced: 5.2.0.4

Example: Hypothetical filter using the map after putting `{sku-a: 12}` into `stock`.

-   [Java](#tab-panel-1308)
-   [Python](#tab-panel-1309)
-   [C](#tab-panel-1310)
-   [Go](#tab-panel-1311)
-   [C#](#tab-panel-1312)
-   [Node.js](#tab-panel-1313)

```java
import com.aerospike.client.cdt.MapPolicy;

import com.aerospike.client.exp.Expression;

import com.aerospike.client.exp.Exp;

import com.aerospike.client.exp.MapExp;

Expression exp = Exp.build(

    Exp.gt(

        MapExp.size(MapExp.put(MapPolicy.Default, Exp.val("sku-a"), Exp.val(12), Exp.mapBin("stock"))),

        Exp.val(2)));
```

```python
from aerospike_helpers.expressions import GT, MapBin

from aerospike_helpers.expressions.map import MapPut, MapSize

exp = GT(MapSize(None, MapPut(None, None, "sku-a", 12, MapBin("stock"))), 2).compile()
```

```c
as_map_policy mp;

as_map_policy_init(&mp);

as_exp_build(predexp,

  as_exp_cmp_gt(

    as_exp_map_size(

      NULL,

      as_exp_map_put(NULL, &mp, as_exp_str("sku-a"), as_exp_int(12), as_exp_bin_map("stock"))),

    as_exp_int(2)));
```

```go
// Requires: import as "github.com/aerospike/aerospike-client-go/v6"

_ = as.ExpGreater(

  as.ExpMapSize(

    as.ExpMapPut(

      as.DefaultMapPolicy(),

      as.ExpStringVal("sku-a"),

      as.ExpIntVal(12),

      as.ExpMapBin("stock"),

    ),

  ),

  as.ExpIntVal(2),

)
```

```csharp
Expression exp = Exp.Build(

  Exp.GT(

    MapExp.Size(MapExp.Put(MapPolicy.Default, Exp.Val("sku-a"), Exp.Val(12), Exp.MapBin("stock"))),

    Exp.Val(2)));
```

```javascript
const Aerospike = require('aerospike')

const exp = Aerospike.exp

const filterExp = exp.gt(

  exp.maps.size(exp.maps.put(exp.binMap('stock'), exp.int(12), exp.str('sku-a'), null)),

  exp.int(2),

)
```

---

#### `map_put_items`

```python
map_put_items(context, policy, items, bin)
```

Description: Add elements in `items` to bin. `map_put_items` does not create a new bin if the specified bin does not exist, unlike the [`put_items`](https://aerospike.com/docs/develop/data-types/collections/map/operations#put_items) CDT Map operation, which does create a new bin if the specified bin does not exist.

Arguments: | Name | Type |
| --- | --- |
| `context` | `library_specific` |
| `policy` | `library_specific` |
| `items` | `map_expr` |
| `bin` | `map_bin_expr` |

Returns: `map_bin`

Introduced: 5.2.0.4

Example: Hypothetical filter using the map after merging additional SKU entries into `stock`.

-   [Java](#tab-panel-1314)
-   [Python](#tab-panel-1315)
-   [C](#tab-panel-1316)
-   [Go](#tab-panel-1317)
-   [C#](#tab-panel-1318)
-   [Node.js](#tab-panel-1319)

```java
import com.aerospike.client.cdt.MapPolicy;

import com.aerospike.client.exp.Expression;

import com.aerospike.client.exp.Exp;

import com.aerospike.client.exp.MapExp;

Expression exp = Exp.build(

    Exp.gt(

        MapExp.size(

            MapExp.putItems(

                MapPolicy.Default,

                Exp.val(java.util.Map.of("sku-b", 2, "sku-c", 3)),

                Exp.mapBin("stock"))),

        Exp.val(3)));
```

```python
from aerospike_helpers.expressions import GT, MapBin

from aerospike_helpers.expressions.map import MapPutItems, MapSize

exp = GT(MapSize(None, MapPutItems(None, None, {"sku-b": 2, "sku-c": 3}, MapBin("stock"))), 3).compile()
```

```c
as_map_policy mp;

as_map_policy_init(&mp);

as_hashmap hm;

as_hashmap_init(&hm, 2);

as_hashmap_set(&hm, (as_val*)as_string_new_strdup("sku-b"), (as_val*)as_integer_new(2));

as_hashmap_set(&hm, (as_val*)as_string_new_strdup("sku-c"), (as_val*)as_integer_new(3));

as_exp_build(predexp,

  as_exp_cmp_gt(

    as_exp_map_size(

      NULL, as_exp_map_put_items(NULL, &mp, as_exp_val(&hm), as_exp_bin_map("stock"))),

    as_exp_int(3)));

as_hashmap_destroy(&hm);
```

```go
// Requires: import as "github.com/aerospike/aerospike-client-go/v6"

putMap := map[any]any{"sku-b": 2, "sku-c": 3}

_ = as.ExpGreater(

  as.ExpMapSize(as.ExpMapPutItems(as.DefaultMapPolicy(), as.ExpMapVal(putMap), as.ExpMapBin("stock"))),

  as.ExpIntVal(3),

)
```

```csharp
using System.Collections.Generic;

Expression exp = Exp.Build(

  Exp.GT(

    MapExp.Size(

      MapExp.PutItems(

        MapPolicy.Default,

        Exp.Val(new Dictionary<string, int> { { "sku-b", 2 }, { "sku-c", 3 } }),

        Exp.MapBin("stock"))),

    Exp.Val(3)));
```

```javascript
const Aerospike = require('aerospike')

const exp = Aerospike.exp

const filterExp = exp.gt(

  exp.maps.size(

    exp.maps.putItems(exp.binMap('stock'), exp.map({ 'sku-b': 2, 'sku-c': 3 }), null),

  ),

  exp.int(3),

)
```

---

#### `map_remove_by_index`

```python
map_remove_by_index(context, index, bin)
```

Description: [Remove](https://aerospike.com/develop/data-types/collections/map/operations#remove_by_index) element at **index**.

Arguments: | Name | Type |
| --- | --- |
| `context` | `library_specific` |
| `index` | `integer_expr` |
| `bin` | `map_bin_expr` |

Returns: `map_bin`

Introduced: 5.2.0.4

Example: Hypothetical filter using the map size after removing index `0`.

-   [Java](#tab-panel-1320)
-   [Python](#tab-panel-1321)
-   [C](#tab-panel-1322)
-   [Go](#tab-panel-1323)
-   [C#](#tab-panel-1324)
-   [Node.js](#tab-panel-1325)

```java
import com.aerospike.client.exp.Expression;

import com.aerospike.client.exp.Exp;

import com.aerospike.client.exp.MapExp;

Expression exp = Exp.build(

    Exp.gt(MapExp.size(MapExp.removeByIndex(Exp.val(0), Exp.mapBin("stock"))), Exp.val(0)));
```

```python
from aerospike_helpers.expressions import GT, MapBin

from aerospike_helpers.expressions.map import MapRemoveByIndex, MapSize

exp = GT(MapSize(None, MapRemoveByIndex(None, 0, MapBin("stock"))), 0).compile()
```

```c
as_exp_build(predexp,

  as_exp_cmp_gt(

    as_exp_map_size(NULL, as_exp_map_remove_by_index(NULL, as_exp_int(0), as_exp_bin_map("stock"))),

    as_exp_int(0)));
```

```go
// Requires: import as "github.com/aerospike/aerospike-client-go/v6"

_ = as.ExpGreater(

  as.ExpMapSize(as.ExpMapRemoveByIndex(as.ExpIntVal(0), as.ExpMapBin("stock"))),

  as.ExpIntVal(0),

)
```

```csharp
Expression exp = Exp.Build(

  Exp.GT(MapExp.Size(MapExp.RemoveByIndex(Exp.Val(0), Exp.MapBin("stock"))), Exp.Val(0)));
```

```javascript
const Aerospike = require('aerospike')

const exp = Aerospike.exp

const filterExp = exp.gt(

  exp.maps.size(exp.maps.removeByIndex(exp.binMap('stock'), exp.int(0))),

  exp.int(0),

)
```

---

#### `map_remove_by_index_range`

```python
map_remove_by_index_range(context, index, count, bin)
```

Description: [Remove](https://aerospike.com/develop/data-types/collections/map/operations#remove_by_index_range) **count** element at **index**.

Arguments: | Name | Type |
| --- | --- |
| `context` | `library_specific` |
| `index` | `integer_expr` |
| `count` | `integer_expr` |
| `bin` | `map_bin_expr` |

Returns: `map_bin`

Introduced: 5.2.0.4

Example: Hypothetical filter using the map size after removing one entry at index `0`.

-   [Java](#tab-panel-1326)
-   [Python](#tab-panel-1327)
-   [C](#tab-panel-1328)
-   [Go](#tab-panel-1329)
-   [C#](#tab-panel-1330)
-   [Node.js](#tab-panel-1331)

```java
import com.aerospike.client.cdt.MapReturnType;

import com.aerospike.client.exp.Expression;

import com.aerospike.client.exp.Exp;

import com.aerospike.client.exp.MapExp;

Expression exp = Exp.build(

    Exp.gt(

        MapExp.size(

            MapExp.removeByIndexRange(MapReturnType.NONE, Exp.val(0), Exp.val(1), Exp.mapBin("stock"))),

        Exp.val(0)));
```

```python
from aerospike_helpers.expressions import GT, MapBin

from aerospike_helpers.expressions.map import MapRemoveByIndexRange, MapSize

exp = GT(MapSize(None, MapRemoveByIndexRange(None, 0, 1, MapBin("stock"))), 0).compile()
```

```c
as_exp_build(predexp,

  as_exp_cmp_gt(

    as_exp_map_size(

      NULL,

      as_exp_map_remove_by_index_range(

        NULL, AS_MAP_RETURN_NONE, as_exp_int(0), as_exp_int(1), as_exp_bin_map("stock"))),

    as_exp_int(0)));
```

```go
// Requires: import as "github.com/aerospike/aerospike-client-go/v6"

_ = as.ExpGreater(

  as.ExpMapSize(

    as.ExpMapRemoveByIndexRangeCount(

      as.MapReturnType.NONE,

      as.ExpIntVal(0),

      as.ExpIntVal(1),

      as.ExpMapBin("stock"),

    ),

  ),

  as.ExpIntVal(0),

)
```

```csharp
Expression exp = Exp.Build(

  Exp.GT(

    MapExp.Size(

      MapExp.RemoveByIndexRange(MapReturnType.NONE, Exp.Val(0), Exp.Val(1), Exp.MapBin("stock"))),

    Exp.Val(0)));
```

```javascript
const Aerospike = require('aerospike')

const exp = Aerospike.exp

const maps = Aerospike.maps

const filterExp = exp.gt(

  exp.maps.size(

    exp.maps.removeByIndexRange(exp.binMap('stock'), exp.int(1), exp.int(0), null, maps.returnType.NONE),

  ),

  exp.int(0),

)
```

---

#### `map_remove_by_index_range_to_end`

```python
map_remove_by_index_range_to_end(context, index, bin)
```

Description: [Remove](https://aerospike.com/develop/data-types/collections/map/operations#remove_by_index_range) all element at and after **index**.

Arguments: | Name | Type |
| --- | --- |
| `context` | `library_specific` |
| `index` | `integer_expr` |
| `bin` | `map_bin_expr` |

Returns: `map_bin`

Introduced: 5.2.0.4

Example: Hypothetical filter using the map size after removing from index `1` to the end.

-   [Java](#tab-panel-1332)
-   [Python](#tab-panel-1333)
-   [C](#tab-panel-1334)
-   [Go](#tab-panel-1335)
-   [C#](#tab-panel-1336)
-   [Node.js](#tab-panel-1337)

```java
import com.aerospike.client.cdt.MapReturnType;

import com.aerospike.client.exp.Expression;

import com.aerospike.client.exp.Exp;

import com.aerospike.client.exp.MapExp;

Expression exp = Exp.build(

    Exp.gt(

        MapExp.size(MapExp.removeByIndexRange(MapReturnType.NONE, Exp.val(1), Exp.mapBin("stock"))),

        Exp.val(0)));
```

```python
from aerospike_helpers.expressions import GT, MapBin

from aerospike_helpers.expressions.map import MapRemoveByIndexRangeToEnd, MapSize

exp = GT(MapSize(None, MapRemoveByIndexRangeToEnd(None, 1, MapBin("stock"))), 0).compile()
```

```c
as_exp_build(predexp,

  as_exp_cmp_gt(

    as_exp_map_size(

      NULL,

      as_exp_map_remove_by_index_range_to_end(

        NULL, AS_MAP_RETURN_NONE, as_exp_int(1), as_exp_bin_map("stock"))),

    as_exp_int(0)));
```

```go
// Requires: import as "github.com/aerospike/aerospike-client-go/v6"

_ = as.ExpGreater(

  as.ExpMapSize(

    as.ExpMapRemoveByIndexRange(as.MapReturnType.NONE, as.ExpIntVal(1), as.ExpMapBin("stock")),

  ),

  as.ExpIntVal(0),

)
```

```csharp
Expression exp = Exp.Build(

  Exp.GT(

    MapExp.Size(MapExp.RemoveByIndexRange(MapReturnType.NONE, Exp.Val(1), Exp.MapBin("stock"))),

    Exp.Val(0)));
```

```javascript
const Aerospike = require('aerospike')

const exp = Aerospike.exp

const maps = Aerospike.maps

const filterExp = exp.gt(

  exp.maps.size(

    exp.maps.removeByIndexRangeToEnd(exp.binMap('stock'), exp.int(1), null, maps.returnType.NONE),

  ),

  exp.int(0),

)
```

---

#### `map_remove_by_key`

```python
map_remove_by_key(context, key, bin)
```

Description: [Remove](https://aerospike.com/develop/data-types/collections/map/operations#remove_by_key) element with key **key**.

Arguments: | Name | Type |
| --- | --- |
| `context` | `library_specific` |
| `key` | `expr` |
| `bin` | `map_bin_expr` |

Returns: `map_bin`

Introduced: 5.2.0.4

Example: Hypothetical filter using the map size after removing key `sku-a`.

-   [Java](#tab-panel-1338)
-   [Python](#tab-panel-1339)
-   [C](#tab-panel-1340)
-   [Go](#tab-panel-1341)
-   [C#](#tab-panel-1342)
-   [Node.js](#tab-panel-1343)

```java
import com.aerospike.client.exp.Expression;

import com.aerospike.client.exp.Exp;

import com.aerospike.client.exp.MapExp;

Expression exp = Exp.build(

    Exp.eq(MapExp.size(MapExp.removeByKey(Exp.val("sku-a"), Exp.mapBin("stock"))), Exp.val(2)));
```

```python
from aerospike_helpers.expressions import Eq, MapBin

from aerospike_helpers.expressions.map import MapRemoveByKey, MapSize

exp = Eq(MapSize(None, MapRemoveByKey(None, "sku-a", MapBin("stock"))), 2).compile()
```

```c
as_exp_build(predexp,

  as_exp_cmp_eq(

    as_exp_map_size(NULL, as_exp_map_remove_by_key(NULL, as_exp_str("sku-a"), as_exp_bin_map("stock"))),

    as_exp_int(2)));
```

```go
// Requires: import as "github.com/aerospike/aerospike-client-go/v6"

_ = as.ExpEq(

  as.ExpMapSize(as.ExpMapRemoveByKey(as.ExpStringVal("sku-a"), as.ExpMapBin("stock"))),

  as.ExpIntVal(2),

)
```

```csharp
Expression exp = Exp.Build(

  Exp.EQ(MapExp.Size(MapExp.RemoveByKey(Exp.Val("sku-a"), Exp.MapBin("stock"))), Exp.Val(2)));
```

```javascript
const Aerospike = require('aerospike')

const exp = Aerospike.exp

const filterExp = exp.eq(exp.maps.size(exp.maps.removeByKey(exp.binMap('stock'), exp.str('sku-a'))), exp.int(2))
```

---

#### `map_remove_by_key_list`

```python
map_remove_by_key_list(context, keys, bin)
```

Description: [Remove](https://aerospike.com/develop/data-types/collections/map/operations#remove_all_by_key_list) all elements where key ∈ **keys**.

Arguments: | Name | Type |
| --- | --- |
| `context` | `library_specific` |
| `keys` | `list_expr` |
| `bin` | `map_bin_expr` |

Returns: `map_bin`

Introduced: 5.2.0.4

Example: Hypothetical filter using the map size after removing two keys.

-   [Java](#tab-panel-1344)
-   [Python](#tab-panel-1345)
-   [C](#tab-panel-1346)
-   [Go](#tab-panel-1347)
-   [C#](#tab-panel-1348)
-   [Node.js](#tab-panel-1349)

```java
import com.aerospike.client.cdt.MapReturnType;

import com.aerospike.client.exp.Expression;

import com.aerospike.client.exp.Exp;

import com.aerospike.client.exp.MapExp;

import java.util.Arrays;

Expression exp = Exp.build(

    Exp.eq(

        MapExp.size(

            MapExp.removeByKeyList(

                MapReturnType.NONE,

                Exp.val(Arrays.asList("sku-a", "sku-b")),

                Exp.mapBin("stock"))),

        Exp.val(1)));
```

```python
from aerospike_helpers.expressions import Eq, MapBin

from aerospike_helpers.expressions.map import MapRemoveByKeyList, MapSize

exp = Eq(MapSize(None, MapRemoveByKeyList(None, ["sku-a", "sku-b"], MapBin("stock"))), 1).compile()
```

```c
as_arraylist rk;

as_arraylist_init(&rk, 2, 2);

as_arraylist_append_str(&rk, "sku-a");

as_arraylist_append_str(&rk, "sku-b");

as_exp_build(predexp,

  as_exp_cmp_eq(

    as_exp_map_size(

      NULL,

      as_exp_map_remove_by_key_list(NULL, AS_MAP_RETURN_NONE, as_exp_val(&rk), as_exp_bin_map("stock"))),

    as_exp_int(1)));

as_arraylist_destroy(&rk);
```

```go
// Requires: import as "github.com/aerospike/aerospike-client-go/v6"

_ = as.ExpEq(

  as.ExpMapSize(

    as.ExpMapRemoveByKeyList(

      as.MapReturnType.NONE,

      as.ExpListVal(as.NewValue("sku-a"), as.NewValue("sku-b")),

      as.ExpMapBin("stock"),

    ),

  ),

  as.ExpIntVal(1),

)
```

```csharp
using System.Collections.Generic;

Expression exp = Exp.Build(

  Exp.EQ(

    MapExp.Size(

      MapExp.RemoveByKeyList(MapReturnType.NONE, Exp.Val(new List<string> { "sku-a", "sku-b" }), Exp.MapBin("stock"))),

    Exp.Val(1)));
```

```javascript
const Aerospike = require('aerospike')

const exp = Aerospike.exp

const maps = Aerospike.maps

const filterExp = exp.eq(

  exp.maps.size(

    exp.maps.removeByKeyList(exp.binMap('stock'), exp.list(['sku-a', 'sku-b']), null, maps.returnType.NONE),

  ),

  exp.int(1),

)
```

---

#### `map_remove_by_key_range`

```python
map_remove_by_key_range(context, start, end, bin)
```

Description: [Remove](https://aerospike.com/develop/data-types/collections/map/operations#remove_by_key_interval) all elements with key k in interval **start** ≤ k < **end**.

Arguments: | Name | Type |
| --- | --- |
| `context` | `library_specific` |
| `start` | `expr` |
| `end` | `expr` |
| `bin` | `map_bin_expr` |

Returns: `map_bin`

Introduced: 5.2.0.4

Example: Hypothetical filter using the map size after removing a key interval.

-   [Java](#tab-panel-1356)
-   [Python](#tab-panel-1357)
-   [C](#tab-panel-1358)
-   [Go](#tab-panel-1359)
-   [C#](#tab-panel-1360)
-   [Node.js](#tab-panel-1361)

```java
import com.aerospike.client.cdt.MapReturnType;

import com.aerospike.client.exp.Expression;

import com.aerospike.client.exp.Exp;

import com.aerospike.client.exp.MapExp;

Expression exp = Exp.build(

    Exp.gt(

        MapExp.size(

            MapExp.removeByKeyRange(

                MapReturnType.NONE, Exp.val("sku-a"), Exp.val("sku-z"), Exp.mapBin("stock"))),

        Exp.val(0)));
```

```python
from aerospike_helpers.expressions import GT, MapBin

from aerospike_helpers.expressions.map import MapRemoveByKeyRange, MapSize

exp = GT(MapSize(None, MapRemoveByKeyRange(None, "sku-a", "sku-z", MapBin("stock"))), 0).compile()
```

```c
as_exp_build(predexp,

  as_exp_cmp_gt(

    as_exp_map_size(

      NULL,

      as_exp_map_remove_by_key_range(

        NULL, AS_MAP_RETURN_NONE, as_exp_str("sku-a"), as_exp_str("sku-z"), as_exp_bin_map("stock"))),

    as_exp_int(0)));
```

```go
// Requires: import as "github.com/aerospike/aerospike-client-go/v6"

_ = as.ExpGreater(

  as.ExpMapSize(

    as.ExpMapRemoveByKeyRange(

      as.MapReturnType.NONE,

      as.ExpStringVal("sku-a"),

      as.ExpStringVal("sku-z"),

      as.ExpMapBin("stock"),

    ),

  ),

  as.ExpIntVal(0),

)
```

```csharp
Expression exp = Exp.Build(

  Exp.GT(

    MapExp.Size(

      MapExp.RemoveByKeyRange(MapReturnType.NONE, Exp.Val("sku-a"), Exp.Val("sku-z"), Exp.MapBin("stock"))),

    Exp.Val(0)));
```

```javascript
const Aerospike = require('aerospike')

const exp = Aerospike.exp

const maps = Aerospike.maps

const filterExp = exp.gt(

  exp.maps.size(

    exp.maps.removeByKeyRange(

      exp.binMap('stock'),

      exp.str('sku-z'),

      exp.str('sku-a'),

      null,

      maps.returnType.NONE,

    ),

  ),

  exp.int(0),

)
```

---

#### `map_remove_by_rank`

```python
map_remove_by_rank(context, rank, bin)
```

Description: [Remove](https://aerospike.com/develop/data-types/collections/map/operations#remove_by_rank) all element with rank **rank**.

Arguments: | Name | Type |
| --- | --- |
| `context` | `library_specific` |
| `rank` | `integer_expr` |
| `bin` | `map_bin_expr` |

Returns: `map_bin`

Introduced: 5.2.0.4

Example: Hypothetical filter using the map size after removing rank `0`.

-   [Java](#tab-panel-1350)
-   [Python](#tab-panel-1351)
-   [C](#tab-panel-1352)
-   [Go](#tab-panel-1353)
-   [C#](#tab-panel-1354)
-   [Node.js](#tab-panel-1355)

```java
import com.aerospike.client.exp.Expression;

import com.aerospike.client.exp.Exp;

import com.aerospike.client.exp.MapExp;

Expression exp = Exp.build(

    Exp.gt(MapExp.size(MapExp.removeByRank(Exp.val(0), Exp.mapBin("stock"))), Exp.val(0)));
```

```python
from aerospike_helpers.expressions import GT, MapBin

from aerospike_helpers.expressions.map import MapRemoveByRank, MapSize

exp = GT(MapSize(None, MapRemoveByRank(None, 0, MapBin("stock"))), 0).compile()
```

```c
as_exp_build(predexp,

  as_exp_cmp_gt(

    as_exp_map_size(NULL, as_exp_map_remove_by_rank(NULL, as_exp_int(0), as_exp_bin_map("stock"))),

    as_exp_int(0)));
```

```go
// Requires: import as "github.com/aerospike/aerospike-client-go/v6"

_ = as.ExpGreater(

  as.ExpMapSize(as.ExpMapRemoveByRank(as.ExpIntVal(0), as.ExpMapBin("stock"))),

  as.ExpIntVal(0),

)
```

```csharp
Expression exp = Exp.Build(

  Exp.GT(MapExp.Size(MapExp.RemoveByRank(Exp.Val(0), Exp.MapBin("stock"))), Exp.Val(0)));
```

```javascript
const Aerospike = require('aerospike')

const exp = Aerospike.exp

const filterExp = exp.gt(

  exp.maps.size(exp.maps.removeByRank(exp.binMap('stock'), exp.int(0))),

  exp.int(0),

)
```

---

#### `map_remove_by_rank_range`

```python
map_remove_by_rank_range(context, rank, count, bin)
```

Description: [Remove](https://aerospike.com/develop/data-types/collections/map/operations#remove_by_rank_range) **count** element at **rank**.

Arguments: | Name | Type |
| --- | --- |
| `context` | `library_specific` |
| `rank` | `integer_expr` |
| `count` | `integer_expr` |
| `bin` | `map_bin_expr` |

Returns: `map_bin`

Introduced: 5.2.0.4

Example: Hypothetical filter using the map size after removing two ranks starting at `0`.

-   [Java](#tab-panel-1362)
-   [Python](#tab-panel-1363)
-   [C](#tab-panel-1364)
-   [Go](#tab-panel-1365)
-   [C#](#tab-panel-1366)
-   [Node.js](#tab-panel-1367)

```java
import com.aerospike.client.cdt.MapReturnType;

import com.aerospike.client.exp.Expression;

import com.aerospike.client.exp.Exp;

import com.aerospike.client.exp.MapExp;

Expression exp = Exp.build(

    Exp.gt(

        MapExp.size(

            MapExp.removeByRankRange(MapReturnType.NONE, Exp.val(0), Exp.val(2), Exp.mapBin("stock"))),

        Exp.val(0)));
```

```python
from aerospike_helpers.expressions import GT, MapBin

from aerospike_helpers.expressions.map import MapRemoveByRankRange, MapSize

exp = GT(MapSize(None, MapRemoveByRankRange(None, 0, 2, MapBin("stock"))), 0).compile()
```

```c
as_exp_build(predexp,

  as_exp_cmp_gt(

    as_exp_map_size(

      NULL,

      as_exp_map_remove_by_rank_range(

        NULL, AS_MAP_RETURN_NONE, as_exp_int(0), as_exp_int(2), as_exp_bin_map("stock"))),

    as_exp_int(0)));
```

```go
// Requires: import as "github.com/aerospike/aerospike-client-go/v6"

_ = as.ExpGreater(

  as.ExpMapSize(

    as.ExpMapRemoveByRankRangeCount(

      as.MapReturnType.NONE,

      as.ExpIntVal(0),

      as.ExpIntVal(2),

      as.ExpMapBin("stock"),

    ),

  ),

  as.ExpIntVal(0),

)
```

```csharp
Expression exp = Exp.Build(

  Exp.GT(

    MapExp.Size(

      MapExp.RemoveByRankRange(MapReturnType.NONE, Exp.Val(0), Exp.Val(2), Exp.MapBin("stock"))),

    Exp.Val(0)));
```

```javascript
const Aerospike = require('aerospike')

const exp = Aerospike.exp

const maps = Aerospike.maps

const filterExp = exp.gt(

  exp.maps.size(

    exp.maps.removeByRankRange(exp.binMap('stock'), exp.int(2), exp.int(0), null, maps.returnType.NONE),

  ),

  exp.int(0),

)
```

---

#### `map_remove_by_rank_range_to_end`

```python
map_remove_by_rank_range_to_end(context, rank, bin)
```

Description: [Remove](https://aerospike.com/develop/data-types/collections/map/operations#remove_by_rank_range) all elements at and after **rank**.

Arguments: | Name | Type |
| --- | --- |
| `context` | `library_specific` |
| `rank` | `integer_expr` |
| `bin` | `map_bin_expr` |

Returns: `map_bin`

Introduced: 5.2.0.4

Example: Hypothetical filter using the map size after removing from rank `0` to the last rank.

-   [Java](#tab-panel-1368)
-   [Python](#tab-panel-1369)
-   [C](#tab-panel-1370)
-   [Go](#tab-panel-1371)
-   [C#](#tab-panel-1372)
-   [Node.js](#tab-panel-1373)

```java
import com.aerospike.client.cdt.MapReturnType;

import com.aerospike.client.exp.Expression;

import com.aerospike.client.exp.Exp;

import com.aerospike.client.exp.MapExp;

Expression exp = Exp.build(

    Exp.gt(

        MapExp.size(MapExp.removeByRankRange(MapReturnType.NONE, Exp.val(0), Exp.mapBin("stock"))),

        Exp.val(0)));
```

```python
from aerospike_helpers.expressions import GT, MapBin

from aerospike_helpers.expressions.map import MapRemoveByRankRangeToEnd, MapSize

exp = GT(MapSize(None, MapRemoveByRankRangeToEnd(None, 0, MapBin("stock"))), 0).compile()
```

```c
as_exp_build(predexp,

  as_exp_cmp_gt(

    as_exp_map_size(

      NULL,

      as_exp_map_remove_by_rank_range_to_end(

        NULL, AS_MAP_RETURN_NONE, as_exp_int(0), as_exp_bin_map("stock"))),

    as_exp_int(0)));
```

```go
// Requires: import as "github.com/aerospike/aerospike-client-go/v6"

_ = as.ExpGreater(

  as.ExpMapSize(

    as.ExpMapRemoveByRankRange(as.MapReturnType.NONE, as.ExpIntVal(0), as.ExpMapBin("stock")),

  ),

  as.ExpIntVal(0),

)
```

```csharp
Expression exp = Exp.Build(

  Exp.GT(

    MapExp.Size(MapExp.RemoveByRankRange(MapReturnType.NONE, Exp.Val(0), Exp.MapBin("stock"))),

    Exp.Val(0)));
```

```javascript
const Aerospike = require('aerospike')

const exp = Aerospike.exp

const maps = Aerospike.maps

const filterExp = exp.gt(

  exp.maps.size(

    exp.maps.removeByRankRangeToEnd(exp.binMap('stock'), exp.int(0), null, maps.returnType.NONE),

  ),

  exp.int(0),

)
```

---

#### `map_remove_by_rel_index_range`

```python
map_remove_by_rel_index_range(context, key, index, count, bin)
```

Description: [Remove](https://aerospike.com/develop/data-types/collections/map/operations#remove_by_key_rel_index_range) **count** elements at **index** relative to **key**.

Arguments: | Name | Type |
| --- | --- |
| `context` | `library_specific` |
| `key` | `expr` |
| `index` | `integer_expr` |
| `count` | `integer_expr` |
| `bin` | `map_bin_expr` |

Returns: `map_bin`

Introduced: 5.2.0.4

Example: Hypothetical filter using the map size after a key-relative index remove with count.

-   [Java](#tab-panel-1374)
-   [Python](#tab-panel-1375)
-   [C](#tab-panel-1376)
-   [Go](#tab-panel-1377)
-   [C#](#tab-panel-1378)
-   [Node.js](#tab-panel-1379)

```java
import com.aerospike.client.cdt.MapReturnType;

import com.aerospike.client.exp.Expression;

import com.aerospike.client.exp.Exp;

import com.aerospike.client.exp.MapExp;

Expression exp = Exp.build(

    Exp.gt(

        MapExp.size(

            MapExp.removeByKeyRelativeIndexRange(

                MapReturnType.NONE, Exp.val("sku-a"), Exp.val(0), Exp.val(1), Exp.mapBin("stock"))),

        Exp.val(0)));
```

```python
from aerospike_helpers.expressions import GT, MapBin

from aerospike_helpers.expressions.map import MapRemoveByKeyRelIndexRange, MapSize

exp = GT(

    MapSize(None, MapRemoveByKeyRelIndexRange(None, "sku-a", 0, 1, MapBin("stock"))),

    0,

).compile()
```

```c
as_exp_build(predexp,

  as_exp_cmp_gt(

    as_exp_map_size(

      NULL,

      as_exp_map_remove_by_key_rel_index_range(

        NULL, AS_MAP_RETURN_NONE, as_exp_str("sku-a"), as_exp_int(0), as_exp_int(1),

        as_exp_bin_map("stock"))),

    as_exp_int(0)));
```

```go
// Requires: import as "github.com/aerospike/aerospike-client-go/v6"

_ = as.ExpGreater(

  as.ExpMapSize(

    as.ExpMapRemoveByKeyRelativeIndexRangeCount(

      as.MapReturnType.NONE,

      as.ExpStringVal("sku-a"),

      as.ExpIntVal(0),

      as.ExpIntVal(1),

      as.ExpMapBin("stock"),

    ),

  ),

  as.ExpIntVal(0),

)
```

```csharp
Expression exp = Exp.Build(

  Exp.GT(

    MapExp.Size(

      MapExp.RemoveByKeyRelativeIndexRange(

        MapReturnType.NONE, Exp.Val("sku-a"), Exp.Val(0), Exp.Val(1), Exp.MapBin("stock"))),

    Exp.Val(0)));
```

```javascript
const Aerospike = require('aerospike')

const exp = Aerospike.exp

const maps = Aerospike.maps

const filterExp = exp.gt(

  exp.maps.size(

    exp.maps.removeByKeyRelIndexRange(

      exp.binMap('stock'),

      exp.int(1),

      exp.int(0),

      exp.str('sku-a'),

      null,

      maps.returnType.NONE,

    ),

  ),

  exp.int(0),

)
```

---

#### `map_remove_by_rel_index_range_to_end`

```python
map_remove_by_rel_index_range_to_end(context, key, index, bin)
```

Description: [Remove](https://aerospike.com/develop/data-types/collections/map/operations#remove_by_key_rel_index_range) all elements at and after **index** relative to **key**.

Arguments: | Name | Type |
| --- | --- |
| `context` | `library_specific` |
| `key` | `expr` |
| `index` | `integer_expr` |
| `bin` | `map_bin_expr` |

Returns: `map_bin`

Introduced: 5.2.0.4

Example: Hypothetical filter using the map size after a key-relative index remove to end.

-   [Java](#tab-panel-1380)
-   [Python](#tab-panel-1381)
-   [C](#tab-panel-1382)
-   [Go](#tab-panel-1383)
-   [C#](#tab-panel-1384)
-   [Node.js](#tab-panel-1385)

```java
import com.aerospike.client.cdt.MapReturnType;

import com.aerospike.client.exp.Expression;

import com.aerospike.client.exp.Exp;

import com.aerospike.client.exp.MapExp;

Expression exp = Exp.build(

    Exp.gt(

        MapExp.size(

            MapExp.removeByKeyRelativeIndexRange(

                MapReturnType.NONE, Exp.val("sku-a"), Exp.val(0), Exp.mapBin("stock"))),

        Exp.val(0)));
```

```python
from aerospike_helpers.expressions import GT, MapBin

from aerospike_helpers.expressions.map import MapRemoveByKeyRelIndexRangeToEnd, MapSize

exp = GT(MapSize(None, MapRemoveByKeyRelIndexRangeToEnd(None, "sku-a", 0, MapBin("stock"))), 0).compile()
```

```c
as_exp_build(predexp,

  as_exp_cmp_gt(

    as_exp_map_size(

      NULL,

      as_exp_map_remove_by_key_rel_index_range_to_end(

        NULL, AS_MAP_RETURN_NONE, as_exp_str("sku-a"), as_exp_int(0), as_exp_bin_map("stock"))),

    as_exp_int(0)));
```

```go
// Requires: import as "github.com/aerospike/aerospike-client-go/v6"

_ = as.ExpGreater(

  as.ExpMapSize(

    as.ExpMapRemoveByKeyRelativeIndexRange(

      as.MapReturnType.NONE,

      as.ExpStringVal("sku-a"),

      as.ExpIntVal(0),

      as.ExpMapBin("stock"),

    ),

  ),

  as.ExpIntVal(0),

)
```

```csharp
Expression exp = Exp.Build(

  Exp.GT(

    MapExp.Size(

      MapExp.RemoveByKeyRelativeIndexRange(MapReturnType.NONE, Exp.Val("sku-a"), Exp.Val(0), Exp.MapBin("stock"))),

    Exp.Val(0)));
```

```javascript
const Aerospike = require('aerospike')

const exp = Aerospike.exp

const maps = Aerospike.maps

const filterExp = exp.gt(

  exp.maps.size(

    exp.maps.removeByKeyRelIndexRangeToEnd(

      exp.binMap('stock'),

      exp.int(0),

      exp.str('sku-a'),

      null,

      maps.returnType.NONE,

    ),

  ),

  exp.int(0),

)
```

---

#### `map_remove_by_rel_rank_range`

```python
map_remove_by_rel_rank_range(context, value, rank, count, bin)
```

Description: [Remove](https://aerospike.com/develop/data-types/collections/map/operations#remove_by_value_rel_rank_range) **count** elements at **rank** relative to **value**.

Arguments: | Name | Type |
| --- | --- |
| `context` | `library_specific` |
| `value` | `expr` |
| `rank` | `integer_expr` |
| `count` | `integer_expr` |
| `bin` | `map_bin_expr` |

Returns: `map_bin`

Introduced: 5.2.0.4

Example: Hypothetical filter using the map size after a value-relative rank remove with count.

-   [Java](#tab-panel-1386)
-   [Python](#tab-panel-1387)
-   [C](#tab-panel-1388)
-   [Go](#tab-panel-1389)
-   [C#](#tab-panel-1390)
-   [Node.js](#tab-panel-1391)

```java
import com.aerospike.client.cdt.MapReturnType;

import com.aerospike.client.exp.Expression;

import com.aerospike.client.exp.Exp;

import com.aerospike.client.exp.MapExp;

Expression exp = Exp.build(

    Exp.gt(

        MapExp.size(

            MapExp.removeByValueRelativeRankRange(

                MapReturnType.NONE, Exp.val(5), Exp.val(0), Exp.val(2), Exp.mapBin("stock"))),

        Exp.val(0)));
```

```python
from aerospike_helpers.expressions import GT, MapBin

from aerospike_helpers.expressions.map import MapRemoveByValueRelRankRange, MapSize

exp = GT(MapSize(None, MapRemoveByValueRelRankRange(None, 5, 0, 2, MapBin("stock"))), 0).compile()
```

```c
as_exp_build(predexp,

  as_exp_cmp_gt(

    as_exp_map_size(

      NULL,

      as_exp_map_remove_by_value_rel_rank_range(

        NULL, AS_MAP_RETURN_NONE, as_exp_int(5), as_exp_int(0), as_exp_int(2), as_exp_bin_map("stock"))),

    as_exp_int(0)));
```

```go
// Requires: import as "github.com/aerospike/aerospike-client-go/v6"

_ = as.ExpGreater(

  as.ExpMapSize(

    as.ExpMapRemoveByValueRelativeRankRangeCount(

      as.MapReturnType.NONE,

      as.ExpIntVal(5),

      as.ExpIntVal(0),

      as.ExpIntVal(2),

      as.ExpMapBin("stock"),

    ),

  ),

  as.ExpIntVal(0),

)
```

```csharp
Expression exp = Exp.Build(

  Exp.GT(

    MapExp.Size(

      MapExp.RemoveByValueRelativeRankRange(

        MapReturnType.NONE, Exp.Val(5), Exp.Val(0), Exp.Val(2), Exp.MapBin("stock"))),

    Exp.Val(0)));
```

```javascript
const Aerospike = require('aerospike')

const exp = Aerospike.exp

const maps = Aerospike.maps

const filterExp = exp.gt(

  exp.maps.size(

    exp.maps.removeByValueRelRankRange(

      exp.binMap('stock'),

      exp.int(2),

      exp.int(0),

      exp.int(5),

      null,

      maps.returnType.NONE,

    ),

  ),

  exp.int(0),

)
```

---

#### `map_remove_by_rel_rank_range_to_end`

```python
map_remove_by_rel_rank_range_to_end(context, value, rank, bin)
```

Description: [Remove](https://aerospike.com/develop/data-types/collections/map/operations#remove_by_value_rel_rank_range) all elements at and after **rank** relative to **value**.

Arguments: | Name | Type |
| --- | --- |
| `context` | `library_specific` |
| `value` | `expr` |
| `rank` | `integer_expr` |
| `bin` | `map_bin_expr` |

Returns: `map_bin`

Introduced: 5.2.0.4

Example: Hypothetical filter using the map size after a value-relative rank remove to end.

-   [Java](#tab-panel-1398)
-   [Python](#tab-panel-1399)
-   [C](#tab-panel-1400)
-   [Go](#tab-panel-1401)
-   [C#](#tab-panel-1402)
-   [Node.js](#tab-panel-1403)

```java
import com.aerospike.client.cdt.MapReturnType;

import com.aerospike.client.exp.Expression;

import com.aerospike.client.exp.Exp;

import com.aerospike.client.exp.MapExp;

Expression exp = Exp.build(

    Exp.gt(

        MapExp.size(

            MapExp.removeByValueRelativeRankRange(MapReturnType.NONE, Exp.val(5), Exp.val(0), Exp.mapBin("stock"))),

        Exp.val(0)));
```

```python
from aerospike_helpers.expressions import GT, MapBin

from aerospike_helpers.expressions.map import MapRemoveByValueRelRankRangeToEnd, MapSize

exp = GT(MapSize(None, MapRemoveByValueRelRankRangeToEnd(None, 5, 0, MapBin("stock"))), 0).compile()
```

```c
as_exp_build(predexp,

  as_exp_cmp_gt(

    as_exp_map_size(

      NULL,

      as_exp_map_remove_by_value_rel_rank_range_to_end(

        NULL, AS_MAP_RETURN_NONE, as_exp_int(5), as_exp_int(0), as_exp_bin_map("stock"))),

    as_exp_int(0)));
```

```go
// Requires: import as "github.com/aerospike/aerospike-client-go/v6"

_ = as.ExpGreater(

  as.ExpMapSize(

    as.ExpMapRemoveByValueRelativeRankRange(

      as.MapReturnType.NONE,

      as.ExpIntVal(5),

      as.ExpIntVal(0),

      as.ExpMapBin("stock"),

    ),

  ),

  as.ExpIntVal(0),

)
```

```csharp
Expression exp = Exp.Build(

  Exp.GT(

    MapExp.Size(

      MapExp.RemoveByValueRelativeRankRange(MapReturnType.NONE, Exp.Val(5), Exp.Val(0), Exp.MapBin("stock"))),

    Exp.Val(0)));
```

```javascript
const Aerospike = require('aerospike')

const exp = Aerospike.exp

const maps = Aerospike.maps

const filterExp = exp.gt(

  exp.maps.size(

    exp.maps.removeByValueRelRankRangeToEnd(

      exp.binMap('stock'),

      exp.int(0),

      exp.int(5),

      null,

      maps.returnType.NONE,

    ),

  ),

  exp.int(0),

)
```

---

#### `map_remove_by_value`

```python
map_remove_by_value(context, value, bin)
```

Description: [Remove](https://aerospike.com/develop/data-types/collections/map/operations#remove_all_by_value) all element with value **value**.

Arguments: | Name | Type |
| --- | --- |
| `context` | `library_specific` |
| `value` | `expr` |
| `bin` | `map_bin_expr` |

Returns: `map_bin`

Introduced: 5.2.0.4

Example: Hypothetical filter using the map size after removing by value `12`.

-   [Java](#tab-panel-1392)
-   [Python](#tab-panel-1393)
-   [C](#tab-panel-1394)
-   [Go](#tab-panel-1395)
-   [C#](#tab-panel-1396)
-   [Node.js](#tab-panel-1397)

```java
import com.aerospike.client.cdt.MapReturnType;

import com.aerospike.client.exp.Expression;

import com.aerospike.client.exp.Exp;

import com.aerospike.client.exp.MapExp;

Expression exp = Exp.build(

    Exp.gt(MapExp.size(MapExp.removeByValue(MapReturnType.NONE, Exp.val(12), Exp.mapBin("stock"))), Exp.val(0)));
```

```python
from aerospike_helpers.expressions import GT, MapBin

from aerospike_helpers.expressions.map import MapRemoveByValue, MapSize

exp = GT(MapSize(None, MapRemoveByValue(None, 12, MapBin("stock"))), 0).compile()
```

```c
as_exp_build(predexp,

  as_exp_cmp_gt(

    as_exp_map_size(

      NULL, as_exp_map_remove_by_value(NULL, AS_MAP_RETURN_NONE, as_exp_int(12), as_exp_bin_map("stock"))),

    as_exp_int(0)));
```

```go
// Requires: import as "github.com/aerospike/aerospike-client-go/v6"

_ = as.ExpGreater(

  as.ExpMapSize(

    as.ExpMapRemoveByValue(as.MapReturnType.NONE, as.ExpIntVal(12), as.ExpMapBin("stock")),

  ),

  as.ExpIntVal(0),

)
```

```csharp
Expression exp = Exp.Build(

  Exp.GT(

    MapExp.Size(MapExp.RemoveByValue(MapReturnType.NONE, Exp.Val(12), Exp.MapBin("stock"))),

    Exp.Val(0)));
```

```javascript
const Aerospike = require('aerospike')

const exp = Aerospike.exp

const maps = Aerospike.maps

const filterExp = exp.gt(

  exp.maps.size(exp.maps.removeByValue(exp.binMap('stock'), exp.int(12), null, maps.returnType.NONE)),

  exp.int(0),

)
```

---

#### `map_remove_by_value_list`

```python
map_remove_by_value_list(context, values, bin)
```

Description: [Remove](https://aerospike.com/develop/data-types/collections/map/operations#remove_all_by_value_list) all elements where value ∈ **values**.

Arguments: | Name | Type |
| --- | --- |
| `context` | `library_specific` |
| `values` | `list_expr` |
| `bin` | `map_bin_expr` |

Returns: `map_bin`

Introduced: 5.2.0.4

Example: Hypothetical filter using the map size after removing by values `5` and `12`.

-   [Java](#tab-panel-1404)
-   [Python](#tab-panel-1405)
-   [C](#tab-panel-1406)
-   [Go](#tab-panel-1407)
-   [C#](#tab-panel-1408)
-   [Node.js](#tab-panel-1409)

```java
import com.aerospike.client.cdt.MapReturnType;

import com.aerospike.client.exp.Expression;

import com.aerospike.client.exp.Exp;

import com.aerospike.client.exp.MapExp;

import java.util.Arrays;

Expression exp = Exp.build(

    Exp.gt(

        MapExp.size(

            MapExp.removeByValueList(MapReturnType.NONE, Exp.val(Arrays.asList(5, 12)), Exp.mapBin("stock"))),

        Exp.val(0)));
```

```python
from aerospike_helpers.expressions import GT, MapBin

from aerospike_helpers.expressions.map import MapRemoveByValueList, MapSize

exp = GT(MapSize(None, MapRemoveByValueList(None, [5, 12], MapBin("stock"))), 0).compile()
```

```c
as_arraylist rv;

as_arraylist_init(&rv, 2, 2);

as_arraylist_append_int64(&rv, 5);

as_arraylist_append_int64(&rv, 12);

as_exp_build(predexp,

  as_exp_cmp_gt(

    as_exp_map_size(

      NULL,

      as_exp_map_remove_by_value_list(NULL, AS_MAP_RETURN_NONE, as_exp_val(&rv), as_exp_bin_map("stock"))),

    as_exp_int(0)));

as_arraylist_destroy(&rv);
```

```go
// Requires: import as "github.com/aerospike/aerospike-client-go/v6"

_ = as.ExpGreater(

  as.ExpMapSize(

    as.ExpMapRemoveByValueList(

      as.MapReturnType.NONE,

      as.ExpListVal(as.NewValue(5), as.NewValue(12)),

      as.ExpMapBin("stock"),

    ),

  ),

  as.ExpIntVal(0),

)
```

```csharp
using System.Collections.Generic;

Expression exp = Exp.Build(

  Exp.GT(

    MapExp.Size(

      MapExp.RemoveByValueList(MapReturnType.NONE, Exp.Val(new List<long> { 5, 12 }), Exp.MapBin("stock"))),

    Exp.Val(0)));
```

```javascript
const Aerospike = require('aerospike')

const exp = Aerospike.exp

const maps = Aerospike.maps

const filterExp = exp.gt(

  exp.maps.size(

    exp.maps.removeByValueList(exp.binMap('stock'), exp.list([5, 12]), null, maps.returnType.NONE),

  ),

  exp.int(0),

)
```

---

#### `map_remove_by_value_range`

```python
map_remove_by_value_range(context, start, end, bin)
```

Description: [Remove](https://aerospike.com/develop/data-types/collections/map/operations#remove_by_value_interval) all elements with value v in interval **start** ≤ v < **end**.

Arguments: | Name | Type |
| --- | --- |
| `context` | `library_specific` |
| `start` | `expr` |
| `end` | `expr` |
| `bin` | `map_bin_expr` |

Returns: `map_bin`

Introduced: 5.2.0.4

Example: Hypothetical filter using the map size after removing values in `[5, 20)`.

-   [Java](#tab-panel-1410)
-   [Python](#tab-panel-1411)
-   [C](#tab-panel-1412)
-   [Go](#tab-panel-1413)
-   [C#](#tab-panel-1414)
-   [Node.js](#tab-panel-1415)

```java
import com.aerospike.client.cdt.MapReturnType;

import com.aerospike.client.exp.Expression;

import com.aerospike.client.exp.Exp;

import com.aerospike.client.exp.MapExp;

Expression exp = Exp.build(

    Exp.gt(

        MapExp.size(

            MapExp.removeByValueRange(MapReturnType.NONE, Exp.val(5), Exp.val(20), Exp.mapBin("stock"))),

        Exp.val(0)));
```

```python
from aerospike_helpers.expressions import GT, MapBin

from aerospike_helpers.expressions.map import MapRemoveByValueRange, MapSize

exp = GT(MapSize(None, MapRemoveByValueRange(None, 5, 20, MapBin("stock"))), 0).compile()
```

```c
as_exp_build(predexp,

  as_exp_cmp_gt(

    as_exp_map_size(

      NULL,

      as_exp_map_remove_by_value_range(

        NULL, AS_MAP_RETURN_NONE, as_exp_int(5), as_exp_int(20), as_exp_bin_map("stock"))),

    as_exp_int(0)));
```

```go
// Requires: import as "github.com/aerospike/aerospike-client-go/v6"

_ = as.ExpGreater(

  as.ExpMapSize(

    as.ExpMapRemoveByValueRange(

      as.MapReturnType.NONE,

      as.ExpIntVal(5),

      as.ExpIntVal(20),

      as.ExpMapBin("stock"),

    ),

  ),

  as.ExpIntVal(0),

)
```

```csharp
Expression exp = Exp.Build(

  Exp.GT(

    MapExp.Size(

      MapExp.RemoveByValueRange(MapReturnType.NONE, Exp.Val(5), Exp.Val(20), Exp.MapBin("stock"))),

    Exp.Val(0)));
```

```javascript
const Aerospike = require('aerospike')

const exp = Aerospike.exp

const maps = Aerospike.maps

const filterExp = exp.gt(

  exp.maps.size(

    exp.maps.removeByValueRange(exp.binMap('stock'), exp.int(20), exp.int(5), null, maps.returnType.NONE),

  ),

  exp.int(0),

)
```

---

## Read

#### `map_get_by_index`

```python
map_get_by_index(type, context, result_type, index, bin)
```

Description: [Get](https://aerospike.com/develop/data-types/collections/map/operations#get_by_index) element at **index**.

Arguments: | Name | Type |
| --- | --- |
| `type` | `integer_value` |
| `context` | `library_specific` |
| `result_type` | `integer_value` |
| `index` | `integer_expr` |
| `bin` | `map_bin_expr` |

Introduced: 5.2.0.4

Example: Filter where the integer value at map index `0` equals `12`.

-   [Java](#tab-panel-1416)
-   [Python](#tab-panel-1417)
-   [C](#tab-panel-1418)
-   [Go](#tab-panel-1419)
-   [C#](#tab-panel-1420)
-   [Node.js](#tab-panel-1421)

```java
import com.aerospike.client.cdt.MapReturnType;

import com.aerospike.client.exp.Expression;

import com.aerospike.client.exp.Exp;

import com.aerospike.client.exp.MapExp;

Expression exp = Exp.build(

    Exp.eq(

        MapExp.getByIndex(MapReturnType.VALUE, Exp.Type.INT, Exp.val(0), Exp.mapBin("stock")),

        Exp.val(12)));
```

```python
import aerospike

from aerospike_helpers.expressions import Eq, MapBin, ResultType

from aerospike_helpers.expressions.map import MapGetByIndex

exp = Eq(

    MapGetByIndex(None, aerospike.MAP_RETURN_VALUE, ResultType.INTEGER, 0, MapBin("stock")),

    12,

).compile()
```

```c
as_exp_build(predexp,

  as_exp_cmp_eq(

    as_exp_map_get_by_index(

      NULL, AS_MAP_RETURN_VALUE, AS_EXP_TYPE_INT, as_exp_int(0), as_exp_bin_map("stock")),

    as_exp_int(12)));
```

```go
// Requires: import as "github.com/aerospike/aerospike-client-go/v6"

_ = as.ExpEq(

  as.ExpMapGetByIndex(as.MapReturnType.VALUE, as.ExpTypeINT, as.ExpIntVal(0), as.ExpMapBin("stock")),

  as.ExpIntVal(12),

)
```

```csharp
Expression exp = Exp.Build(

  Exp.EQ(

    MapExp.GetByIndex(MapReturnType.VALUE, Exp.Type.INT, Exp.Val(0), Exp.MapBin("stock")),

    Exp.Val(12)));
```

```javascript
const Aerospike = require('aerospike')

const exp = Aerospike.exp

const maps = Aerospike.maps

const filterExp = exp.eq(

  exp.maps.getByIndex(exp.binMap('stock'), exp.int(0), exp.type.INT, maps.returnType.VALUE),

  exp.int(12),

)
```

---

#### `map_get_by_index_range`

```python
map_get_by_index_range(context, result_type, index, count, bin)
```

Description: [Get](https://aerospike.com/develop/data-types/collections/map/operations#get_by_index_range) **count** elements at **index**.

Arguments: | Name | Type |
| --- | --- |
| `context` | `library_specific` |
| `result_type` | `integer_value` |
| `index` | `integer_expr` |
| `count` | `integer_expr` |
| `bin` | `map_bin_expr` |

Introduced: 5.2.0.4

Example: Filter where two entries exist starting at map index `0`.

-   [Java](#tab-panel-1422)
-   [Python](#tab-panel-1423)
-   [C](#tab-panel-1424)
-   [Go](#tab-panel-1425)
-   [C#](#tab-panel-1426)
-   [Node.js](#tab-panel-1427)

```java
import com.aerospike.client.cdt.MapReturnType;

import com.aerospike.client.exp.Expression;

import com.aerospike.client.exp.Exp;

import com.aerospike.client.exp.MapExp;

Expression exp = Exp.build(

    Exp.eq(

        MapExp.getByIndexRange(MapReturnType.COUNT, Exp.val(0), Exp.val(2), Exp.mapBin("stock")),

        Exp.val(2)));
```

```python
import aerospike

from aerospike_helpers.expressions import Eq, MapBin

from aerospike_helpers.expressions.map import MapGetByIndexRange

exp = Eq(

    MapGetByIndexRange(None, aerospike.MAP_RETURN_COUNT, 0, 2, MapBin("stock")),

    2,

).compile()
```

```c
as_exp_build(predexp,

  as_exp_cmp_eq(

    as_exp_map_get_by_index_range(

      NULL, AS_MAP_RETURN_COUNT, as_exp_int(0), as_exp_int(2), as_exp_bin_map("stock")),

    as_exp_int(2)));
```

```go
// Requires: import as "github.com/aerospike/aerospike-client-go/v6"

_ = as.ExpEq(

  as.ExpMapGetByIndexRangeCount(

    as.MapReturnType.COUNT,

    as.ExpIntVal(0),

    as.ExpIntVal(2),

    as.ExpMapBin("stock"),

  ),

  as.ExpIntVal(2),

)
```

```csharp
Expression exp = Exp.Build(

  Exp.EQ(

    MapExp.GetByIndexRange(MapReturnType.COUNT, Exp.Val(0), Exp.Val(2), Exp.MapBin("stock")),

    Exp.Val(2)));
```

```javascript
const Aerospike = require('aerospike')

const exp = Aerospike.exp

const maps = Aerospike.maps

const filterExp = exp.eq(

  exp.maps.getByIndexRange(exp.binMap('stock'), exp.int(2), exp.int(0), maps.returnType.COUNT),

  exp.int(2),

)
```

---

#### `map_get_by_index_range_to_end`

```python
map_get_by_index_range_to_end(context, result_type, index, bin)
```

Description: [Get](https://aerospike.com/develop/data-types/collections/map/operations#get_by_index_range) elements at and after **index**.

Arguments: | Name | Type |
| --- | --- |
| `context` | `library_specific` |
| `result_type` | `integer_value` |
| `index` | `integer_expr` |
| `bin` | `map_bin_expr` |

Introduced: 5.2.0.4

Example: Filter where the count from index `1` to the end is positive.

-   [Java](#tab-panel-1428)
-   [Python](#tab-panel-1429)
-   [C](#tab-panel-1430)
-   [Go](#tab-panel-1431)
-   [C#](#tab-panel-1432)
-   [Node.js](#tab-panel-1433)

```java
import com.aerospike.client.cdt.MapReturnType;

import com.aerospike.client.exp.Expression;

import com.aerospike.client.exp.Exp;

import com.aerospike.client.exp.MapExp;

Expression exp = Exp.build(

    Exp.gt(MapExp.getByIndexRange(MapReturnType.COUNT, Exp.val(1), Exp.mapBin("stock")), Exp.val(0)));
```

```python
import aerospike

from aerospike_helpers.expressions import GT, MapBin

from aerospike_helpers.expressions.map import MapGetByIndexRangeToEnd

exp = GT(MapGetByIndexRangeToEnd(None, aerospike.MAP_RETURN_COUNT, 1, MapBin("stock")), 0).compile()
```

```c
as_exp_build(predexp,

  as_exp_cmp_gt(

    as_exp_map_get_by_index_range_to_end(

      NULL, AS_MAP_RETURN_COUNT, as_exp_int(1), as_exp_bin_map("stock")),

    as_exp_int(0)));
```

```go
// Requires: import as "github.com/aerospike/aerospike-client-go/v6"

_ = as.ExpGreater(

  as.ExpMapGetByIndexRange(as.MapReturnType.COUNT, as.ExpIntVal(1), as.ExpMapBin("stock")),

  as.ExpIntVal(0),

)
```

```csharp
Expression exp = Exp.Build(

  Exp.GT(

    MapExp.GetByIndexRange(MapReturnType.COUNT, Exp.Val(1), Exp.MapBin("stock")),

    Exp.Val(0)));
```

```javascript
const Aerospike = require('aerospike')

const exp = Aerospike.exp

const maps = Aerospike.maps

const filterExp = exp.gt(

  exp.maps.getByIndexRangeToEnd(exp.binMap('stock'), exp.int(1), maps.returnType.COUNT),

  exp.int(0),

)
```

---

#### `map_get_by_key`

```python
map_get_by_key(type, context, result_type, key, bin)
```

Description: [Get](https://aerospike.com/develop/data-types/collections/map/operations#get_by_key) element with key == **key**.

Arguments: | Name | Type |
| --- | --- |
| `type` | `integer_value` |
| `context` | `library_specific` |
| `result_type` | `integer_value` |
| `key` | `expr` |
| `bin` | `map_bin_expr` |

Introduced: 5.2.0.4

Example: Filter where the integer value at key `sku-a` in `stock` equals `12`.

-   [Java](#tab-panel-1434)
-   [Python](#tab-panel-1435)
-   [C](#tab-panel-1436)
-   [Go](#tab-panel-1437)
-   [C#](#tab-panel-1438)
-   [Node.js](#tab-panel-1439)

```java
import com.aerospike.client.cdt.MapReturnType;

import com.aerospike.client.exp.Expression;

import com.aerospike.client.exp.Exp;

import com.aerospike.client.exp.MapExp;

Expression exp = Exp.build(

    Exp.eq(

        MapExp.getByKey(MapReturnType.VALUE, Exp.Type.INT, Exp.val("sku-a"), Exp.mapBin("stock")),

        Exp.val(12)));
```

```python
import aerospike

from aerospike_helpers.expressions import Eq, MapBin, ResultType

from aerospike_helpers.expressions.map import MapGetByKey

exp = Eq(

    MapGetByKey(None, aerospike.MAP_RETURN_VALUE, ResultType.INTEGER, "sku-a", MapBin("stock")),

    12,

).compile()
```

```c
as_exp_build(predexp,

  as_exp_cmp_eq(

    as_exp_map_get_by_key(

      NULL, AS_MAP_RETURN_VALUE, AS_EXP_TYPE_INT, as_exp_str("sku-a"), as_exp_bin_map("stock")),

    as_exp_int(12)));
```

```go
// Requires: import as "github.com/aerospike/aerospike-client-go/v6"

_ = as.ExpEq(

  as.ExpMapGetByKey(as.MapReturnType.VALUE, as.ExpTypeINT, as.ExpStringVal("sku-a"), as.ExpMapBin("stock")),

  as.ExpIntVal(12),

)
```

```csharp
Expression exp = Exp.Build(

  Exp.EQ(

    MapExp.GetByKey(MapReturnType.VALUE, Exp.Type.INT, Exp.Val("sku-a"), Exp.MapBin("stock")),

    Exp.Val(12)));
```

```javascript
const Aerospike = require('aerospike')

const exp = Aerospike.exp

const maps = Aerospike.maps

const filterExp = exp.eq(

  exp.maps.getByKey(exp.binMap('stock'), exp.str('sku-a'), exp.type.INT, maps.returnType.VALUE),

  exp.int(12),

)
```

---

#### `map_get_by_key_list`

```python
map_get_by_key_list(context, result_type, keys, bin)
```

Description: [Get](https://aerospike.com/develop/data-types/collections/map/operations#get_all_by_key_list) all elements where key ∈ **keys**.

Arguments: | Name | Type |
| --- | --- |
| `context` | `library_specific` |
| `result_type` | `integer_value` |
| `keys` | `list_expr` |
| `bin` | `map_bin_expr` |

Introduced: 5.2.0.4

Example: Filter where the map has positive `COUNT` for keys `sku-a` and `sku-b` in `stock`.

-   [Java](#tab-panel-1440)
-   [Python](#tab-panel-1441)
-   [C](#tab-panel-1442)
-   [Go](#tab-panel-1443)
-   [C#](#tab-panel-1444)
-   [Node.js](#tab-panel-1445)

```java
import com.aerospike.client.cdt.MapReturnType;

import com.aerospike.client.exp.Expression;

import com.aerospike.client.exp.Exp;

import com.aerospike.client.exp.MapExp;

import java.util.Arrays;

Expression exp = Exp.build(

    Exp.gt(

        MapExp.getByKeyList(

            MapReturnType.COUNT, Exp.val(Arrays.asList("sku-a", "sku-b")), Exp.mapBin("stock")),

        Exp.val(0)));
```

```python
import aerospike

from aerospike_helpers.expressions import GT, MapBin

from aerospike_helpers.expressions.map import MapGetByKeyList

exp = GT(

    MapGetByKeyList(None, aerospike.MAP_RETURN_COUNT, ["sku-a", "sku-b"], MapBin("stock")),

    0,

).compile()
```

```c
as_arraylist kl;

as_arraylist_init(&kl, 2, 2);

as_arraylist_append_str(&kl, "sku-a");

as_arraylist_append_str(&kl, "sku-b");

as_exp_build(predexp,

  as_exp_cmp_gt(

    as_exp_map_get_by_key_list(

      NULL, AS_MAP_RETURN_COUNT, as_exp_val(&kl), as_exp_bin_map("stock")),

    as_exp_int(0)));

as_arraylist_destroy(&kl);
```

```go
// Requires: import as "github.com/aerospike/aerospike-client-go/v6"

_ = as.ExpGreater(

  as.ExpMapGetByKeyList(

    as.MapReturnType.COUNT,

    as.ExpListVal(as.NewValue("sku-a"), as.NewValue("sku-b")),

    as.ExpMapBin("stock"),

  ),

  as.ExpIntVal(0),

)
```

```csharp
using System.Collections.Generic;

Expression exp = Exp.Build(

  Exp.GT(

    MapExp.GetByKeyList(MapReturnType.COUNT, Exp.Val(new List<string> { "sku-a", "sku-b" }), Exp.MapBin("stock")),

    Exp.Val(0)));
```

```javascript
const Aerospike = require('aerospike')

const exp = Aerospike.exp

const maps = Aerospike.maps

const filterExp = exp.gt(

  exp.maps.getByKeyList(exp.binMap('stock'), exp.list(['sku-a', 'sku-b']), maps.returnType.COUNT),

  exp.int(0),

)
```

---

#### `map_get_by_key_range`

```python
map_get_by_key_range(context, result_type, start, end, bin)
```

Description: [Get](https://aerospike.com/develop/data-types/collections/map/operations#get_by_key_interval) all elements with key k in interval **start** ≤ k < **end**.

Arguments: | Name | Type |
| --- | --- |
| `context` | `library_specific` |
| `result_type` | `integer_value` |
| `start` | `expr` |
| `end` | `expr` |
| `bin` | `map_bin_expr` |

Introduced: 5.2.0.4

Example: Filter where the count of map entries with keys less than `sku-z` is positive.

-   [Java](#tab-panel-1446)
-   [Python](#tab-panel-1447)
-   [C](#tab-panel-1448)
-   [Go](#tab-panel-1449)
-   [C#](#tab-panel-1450)
-   [Node.js](#tab-panel-1451)

```java
import com.aerospike.client.cdt.MapReturnType;

import com.aerospike.client.exp.Expression;

import com.aerospike.client.exp.Exp;

import com.aerospike.client.exp.MapExp;

Expression exp = Exp.build(

    Exp.gt(

        MapExp.getByKeyRange(MapReturnType.COUNT, Exp.val((String) null), Exp.val("sku-z"), Exp.mapBin("stock")),

        Exp.val(0)));
```

```python
import aerospike

from aerospike_helpers.expressions import GT, MapBin

from aerospike_helpers.expressions.map import MapGetByKeyRange

exp = GT(

    MapGetByKeyRange(None, aerospike.MAP_RETURN_COUNT, None, "sku-z", MapBin("stock")),

    0,

).compile()
```

```c
as_exp_build(predexp,

  as_exp_cmp_gt(

    as_exp_map_get_by_key_range(

      NULL, AS_MAP_RETURN_COUNT, as_exp_nil(), as_exp_str("sku-z"), as_exp_bin_map("stock")),

    as_exp_int(0)));
```

```go
// Requires: import as "github.com/aerospike/aerospike-client-go/v6"

_ = as.ExpGreater(

  as.ExpMapGetByKeyRange(as.MapReturnType.COUNT, nil, as.ExpStringVal("sku-z"), as.ExpMapBin("stock")),

  as.ExpIntVal(0),

)
```

```csharp
Expression exp = Exp.Build(

  Exp.GT(

    MapExp.GetByKeyRange(MapReturnType.COUNT, null, Exp.Val("sku-z"), Exp.MapBin("stock")),

    Exp.Val(0)));
```

```javascript
const Aerospike = require('aerospike')

const exp = Aerospike.exp

const maps = Aerospike.maps

const filterExp = exp.gt(

  exp.maps.getByKeyRange(exp.binMap('stock'), exp.str('sku-z'), exp.nil(), maps.returnType.COUNT),

  exp.int(0),

)
```

---

#### `map_get_by_rank`

```python
map_get_by_rank(type, context, result_type, rank, bin)
```

Description: [Get](https://aerospike.com/develop/data-types/collections/map/operations#get_by_rank) element at **rank**.

Arguments: | Name | Type |
| --- | --- |
| `type` | `integer_value` |
| `context` | `library_specific` |
| `result_type` | `integer_value` |
| `rank` | `integer_expr` |
| `bin` | `map_bin_expr` |

Introduced: 5.2.0.4

Example: Filter where the lowest-ranked value equals `5`.

-   [Java](#tab-panel-1452)
-   [Python](#tab-panel-1453)
-   [C](#tab-panel-1454)
-   [Go](#tab-panel-1455)
-   [C#](#tab-panel-1456)
-   [Node.js](#tab-panel-1457)

```java
import com.aerospike.client.cdt.MapReturnType;

import com.aerospike.client.exp.Expression;

import com.aerospike.client.exp.Exp;

import com.aerospike.client.exp.MapExp;

Expression exp = Exp.build(

    Exp.eq(

        MapExp.getByRank(MapReturnType.VALUE, Exp.Type.INT, Exp.val(0), Exp.mapBin("stock")),

        Exp.val(5)));
```

```python
import aerospike

from aerospike_helpers.expressions import Eq, MapBin, ResultType

from aerospike_helpers.expressions.map import MapGetByRank

exp = Eq(

    MapGetByRank(None, aerospike.MAP_RETURN_VALUE, ResultType.INTEGER, 0, MapBin("stock")),

    5,

).compile()
```

```c
as_exp_build(predexp,

  as_exp_cmp_eq(

    as_exp_map_get_by_rank(

      NULL, AS_MAP_RETURN_VALUE, AS_EXP_TYPE_INT, as_exp_int(0), as_exp_bin_map("stock")),

    as_exp_int(5)));
```

```go
// Requires: import as "github.com/aerospike/aerospike-client-go/v6"

_ = as.ExpEq(

  as.ExpMapGetByRank(as.MapReturnType.VALUE, as.ExpTypeINT, as.ExpIntVal(0), as.ExpMapBin("stock")),

  as.ExpIntVal(5),

)
```

```csharp
Expression exp = Exp.Build(

  Exp.EQ(

    MapExp.GetByRank(MapReturnType.VALUE, Exp.Type.INT, Exp.Val(0), Exp.MapBin("stock")),

    Exp.Val(5)));
```

```javascript
const Aerospike = require('aerospike')

const exp = Aerospike.exp

const maps = Aerospike.maps

const filterExp = exp.eq(

  exp.maps.getByRank(exp.binMap('stock'), exp.int(0), exp.type.INT, maps.returnType.VALUE),

  exp.int(5),

)
```

---

#### `map_get_by_rank_range`

```python
map_get_by_rank_range(context, result_type, rank, count, bin)
```

Description: [Get](https://aerospike.com/develop/data-types/collections/map/operations#get_by_rank_range) **count** element at **rank**.

Arguments: | Name | Type |
| --- | --- |
| `context` | `library_specific` |
| `result_type` | `integer_value` |
| `rank` | `integer_expr` |
| `count` | `integer_expr` |
| `bin` | `map_bin_expr` |

Introduced: 5.2.0.4

Example: Filter where exactly two entries are selected starting at rank `0`.

-   [Java](#tab-panel-1458)
-   [Python](#tab-panel-1459)
-   [C](#tab-panel-1460)
-   [Go](#tab-panel-1461)
-   [C#](#tab-panel-1462)
-   [Node.js](#tab-panel-1463)

```java
import com.aerospike.client.cdt.MapReturnType;

import com.aerospike.client.exp.Expression;

import com.aerospike.client.exp.Exp;

import com.aerospike.client.exp.MapExp;

Expression exp = Exp.build(

    Exp.eq(

        MapExp.getByRankRange(MapReturnType.COUNT, Exp.val(0), Exp.val(2), Exp.mapBin("stock")),

        Exp.val(2)));
```

```python
import aerospike

from aerospike_helpers.expressions import Eq, MapBin

from aerospike_helpers.expressions.map import MapGetByRankRange

exp = Eq(

    MapGetByRankRange(None, aerospike.MAP_RETURN_COUNT, 0, 2, MapBin("stock")),

    2,

).compile()
```

```c
as_exp_build(predexp,

  as_exp_cmp_eq(

    as_exp_map_get_by_rank_range(

      NULL, AS_MAP_RETURN_COUNT, as_exp_int(0), as_exp_int(2), as_exp_bin_map("stock")),

    as_exp_int(2)));
```

```go
// Requires: import as "github.com/aerospike/aerospike-client-go/v6"

_ = as.ExpEq(

  as.ExpMapGetByRankRangeCount(

    as.MapReturnType.COUNT,

    as.ExpIntVal(0),

    as.ExpIntVal(2),

    as.ExpMapBin("stock"),

  ),

  as.ExpIntVal(2),

)
```

```csharp
Expression exp = Exp.Build(

  Exp.EQ(

    MapExp.GetByRankRange(MapReturnType.COUNT, Exp.Val(0), Exp.Val(2), Exp.MapBin("stock")),

    Exp.Val(2)));
```

```javascript
const Aerospike = require('aerospike')

const exp = Aerospike.exp

const maps = Aerospike.maps

const filterExp = exp.eq(

  exp.maps.getByRankRange(exp.binMap('stock'), exp.int(2), exp.int(0), maps.returnType.COUNT),

  exp.int(2),

)
```

---

#### `map_get_by_rank_range_to_end`

```python
map_get_by_rank_range_to_end(context, result_type, rank, bin)
```

Description: [Get](https://aerospike.com/develop/data-types/collections/map/operations#get_by_rank_range) all elements at and after **rank**.

Arguments: | Name | Type |
| --- | --- |
| `context` | `library_specific` |
| `result_type` | `integer_value` |
| `rank` | `integer_expr` |
| `bin` | `map_bin_expr` |

Introduced: 5.2.0.4

Example: Filter where the count from rank `0` to the last rank is positive.

-   [Java](#tab-panel-1464)
-   [Python](#tab-panel-1465)
-   [C](#tab-panel-1466)
-   [Go](#tab-panel-1467)
-   [C#](#tab-panel-1468)
-   [Node.js](#tab-panel-1469)

```java
import com.aerospike.client.cdt.MapReturnType;

import com.aerospike.client.exp.Expression;

import com.aerospike.client.exp.Exp;

import com.aerospike.client.exp.MapExp;

Expression exp = Exp.build(

    Exp.gt(MapExp.getByRankRange(MapReturnType.COUNT, Exp.val(0), Exp.mapBin("stock")), Exp.val(0)));
```

```python
import aerospike

from aerospike_helpers.expressions import GT, MapBin

from aerospike_helpers.expressions.map import MapGetByRankRangeToEnd

exp = GT(MapGetByRankRangeToEnd(None, aerospike.MAP_RETURN_COUNT, 0, MapBin("stock")), 0).compile()
```

```c
as_exp_build(predexp,

  as_exp_cmp_gt(

    as_exp_map_get_by_rank_range_to_end(

      NULL, AS_MAP_RETURN_COUNT, as_exp_int(0), as_exp_bin_map("stock")),

    as_exp_int(0)));
```

```go
// Requires: import as "github.com/aerospike/aerospike-client-go/v6"

_ = as.ExpGreater(

  as.ExpMapGetByRankRange(as.MapReturnType.COUNT, as.ExpIntVal(0), as.ExpMapBin("stock")),

  as.ExpIntVal(0),

)
```

```csharp
Expression exp = Exp.Build(

  Exp.GT(

    MapExp.GetByRankRange(MapReturnType.COUNT, Exp.Val(0), Exp.MapBin("stock")),

    Exp.Val(0)));
```

```javascript
const Aerospike = require('aerospike')

const exp = Aerospike.exp

const maps = Aerospike.maps

const filterExp = exp.gt(

  exp.maps.getByRankRangeToEnd(exp.binMap('stock'), exp.int(0), maps.returnType.COUNT),

  exp.int(0),

)
```

---

#### `map_get_by_rel_index_range`

```python
map_get_by_rel_index_range(context, result_type, key, index, count_expr, bin)
```

Description: [Get](https://aerospike.com/develop/data-types/collections/map/operations#get_by_key_rel_index_range) **count** elements at **index** relative to **key**.

Arguments: | Name | Type |
| --- | --- |
| `context` | `library_specific` |
| `result_type` | `integer_value` |
| `key` | `expr` |
| `index` | `integer_expr` |
| `count_expr` | `integer_expr` |
| `bin` | `map_bin_expr` |

Introduced: 5.2.0.4

Example: Filter where exactly one entry is selected starting at index `0` relative to key `sku-a`.

-   [Java](#tab-panel-1470)
-   [Python](#tab-panel-1471)
-   [C](#tab-panel-1472)
-   [Go](#tab-panel-1473)
-   [C#](#tab-panel-1474)
-   [Node.js](#tab-panel-1475)

```java
import com.aerospike.client.cdt.MapReturnType;

import com.aerospike.client.exp.Expression;

import com.aerospike.client.exp.Exp;

import com.aerospike.client.exp.MapExp;

Expression exp = Exp.build(

    Exp.eq(

        MapExp.getByKeyRelativeIndexRange(

            MapReturnType.COUNT, Exp.val("sku-a"), Exp.val(0), Exp.val(1), Exp.mapBin("stock")),

        Exp.val(1)));
```

```python
import aerospike

from aerospike_helpers.expressions import Eq, MapBin

from aerospike_helpers.expressions.map import MapGetByKeyRelIndexRange

exp = Eq(

    MapGetByKeyRelIndexRange(None, aerospike.MAP_RETURN_COUNT, "sku-a", 0, 1, MapBin("stock")),

    1,

).compile()
```

```c
as_exp_build(predexp,

  as_exp_cmp_eq(

    as_exp_map_get_by_key_rel_index_range(

      NULL, AS_MAP_RETURN_COUNT, as_exp_str("sku-a"), as_exp_int(0), as_exp_int(1),

      as_exp_bin_map("stock")),

    as_exp_int(1)));
```

```go
// Requires: import as "github.com/aerospike/aerospike-client-go/v6"

_ = as.ExpEq(

  as.ExpMapGetByKeyRelativeIndexRangeCount(

    as.MapReturnType.COUNT,

    as.ExpStringVal("sku-a"),

    as.ExpIntVal(0),

    as.ExpIntVal(1),

    as.ExpMapBin("stock"),

  ),

  as.ExpIntVal(1),

)
```

```csharp
Expression exp = Exp.Build(

  Exp.EQ(

    MapExp.GetByKeyRelativeIndexRange(MapReturnType.COUNT, Exp.Val("sku-a"), Exp.Val(0), Exp.Val(1), Exp.MapBin("stock")),

    Exp.Val(1)));
```

```javascript
const Aerospike = require('aerospike')

const exp = Aerospike.exp

const maps = Aerospike.maps

const filterExp = exp.eq(

  exp.maps.getByKeyRelIndexRange(

    exp.binMap('stock'),

    exp.int(1),

    exp.int(0),

    exp.str('sku-a'),

    maps.returnType.COUNT,

  ),

  exp.int(1),

)
```

---

#### `map_get_by_rel_index_range_to_end`

```python
map_get_by_rel_index_range_to_end(context, result_type, key, index_expr, bin)
```

Description: [Get](https://aerospike.com/develop/data-types/collections/map/operations#get_by_key_rel_index_range) all elements at and after **index** relative to **key**.

Arguments: | Name | Type |
| --- | --- |
| `context` | `library_specific` |
| `result_type` | `integer_value` |
| `key` | `expr` |
| `index_expr` |  |
| `bin` | `map_bin_expr` |

Introduced: 5.2.0.4

Example: Filter where the `COUNT` of entries from index `0` relative to key `sku-a` is positive.

-   [Java](#tab-panel-1476)
-   [Python](#tab-panel-1477)
-   [C](#tab-panel-1478)
-   [Go](#tab-panel-1479)
-   [C#](#tab-panel-1480)
-   [Node.js](#tab-panel-1481)

```java
import com.aerospike.client.cdt.MapReturnType;

import com.aerospike.client.exp.Expression;

import com.aerospike.client.exp.Exp;

import com.aerospike.client.exp.MapExp;

Expression exp = Exp.build(

    Exp.gt(

        MapExp.getByKeyRelativeIndexRange(

            MapReturnType.COUNT, Exp.val("sku-a"), Exp.val(0), Exp.mapBin("stock")),

        Exp.val(0)));
```

```python
import aerospike

from aerospike_helpers.expressions import GT, MapBin

from aerospike_helpers.expressions.map import MapGetByKeyRelIndexRangeToEnd

exp = GT(

    MapGetByKeyRelIndexRangeToEnd(None, aerospike.MAP_RETURN_COUNT, "sku-a", 0, MapBin("stock")),

    0,

).compile()
```

```c
as_exp_build(predexp,

  as_exp_cmp_gt(

    as_exp_map_get_by_key_rel_index_range_to_end(

      NULL, AS_MAP_RETURN_COUNT, as_exp_str("sku-a"), as_exp_int(0), as_exp_bin_map("stock")),

    as_exp_int(0)));
```

```go
// Requires: import as "github.com/aerospike/aerospike-client-go/v6"

_ = as.ExpGreater(

  as.ExpMapGetByKeyRelativeIndexRange(

    as.MapReturnType.COUNT,

    as.ExpStringVal("sku-a"),

    as.ExpIntVal(0),

    as.ExpMapBin("stock"),

  ),

  as.ExpIntVal(0),

)
```

```csharp
Expression exp = Exp.Build(

  Exp.GT(

    MapExp.GetByKeyRelativeIndexRange(MapReturnType.COUNT, Exp.Val("sku-a"), Exp.Val(0), Exp.MapBin("stock")),

    Exp.Val(0)));
```

```javascript
const Aerospike = require('aerospike')

const exp = Aerospike.exp

const maps = Aerospike.maps

const filterExp = exp.gt(

  exp.maps.getByKeyRelIndexRangeToEnd(

    exp.binMap('stock'),

    exp.int(0),

    exp.str('sku-a'),

    maps.returnType.COUNT,

  ),

  exp.int(0),

)
```

---

#### `map_get_by_rel_rank_range`

```python
map_get_by_rel_rank_range(context, result_type, value, rank, count, bin)
```

Description: [Get](https://aerospike.com/develop/data-types/collections/map/operations#get_by_value_rel_rank_range) **count** elements at **rank** relative to **value**.

Arguments: | Name | Type |
| --- | --- |
| `context` | `library_specific` |
| `result_type` | `integer_value` |
| `value` | `expr` |
| `rank` | `integer_expr` |
| `count` | `integer_expr` |
| `bin` | `map_bin_expr` |

Introduced: 5.2.0.4

Example: Filter where bounded relative-rank selection from value `5` has positive `COUNT`.

-   [Java](#tab-panel-1482)
-   [Python](#tab-panel-1483)
-   [C](#tab-panel-1484)
-   [Go](#tab-panel-1485)
-   [C#](#tab-panel-1486)
-   [Node.js](#tab-panel-1487)

```java
import com.aerospike.client.cdt.MapReturnType;

import com.aerospike.client.exp.Expression;

import com.aerospike.client.exp.Exp;

import com.aerospike.client.exp.MapExp;

Expression exp = Exp.build(

    Exp.gt(

        MapExp.getByValueRelativeRankRange(

            MapReturnType.COUNT, Exp.val(5), Exp.val(0), Exp.val(2), Exp.mapBin("stock")),

        Exp.val(0)));
```

```python
import aerospike

from aerospike_helpers.expressions import GT, MapBin

from aerospike_helpers.expressions.map import MapGetByValueRelRankRange

exp = GT(

    MapGetByValueRelRankRange(None, aerospike.MAP_RETURN_COUNT, 5, 0, 2, MapBin("stock")),

    0,

).compile()
```

```c
as_exp_build(predexp,

  as_exp_cmp_gt(

    as_exp_map_get_by_value_rel_rank_range(

      NULL, AS_MAP_RETURN_COUNT, as_exp_int(5), as_exp_int(0), as_exp_int(2), as_exp_bin_map("stock")),

    as_exp_int(0)));
```

```go
// Requires: import as "github.com/aerospike/aerospike-client-go/v6"

_ = as.ExpGreater(

  as.ExpMapGetByValueRelativeRankRangeCount(

    as.MapReturnType.COUNT,

    as.ExpIntVal(5),

    as.ExpIntVal(0),

    as.ExpIntVal(2),

    as.ExpMapBin("stock"),

  ),

  as.ExpIntVal(0),

)
```

```csharp
Expression exp = Exp.Build(

  Exp.GT(

    MapExp.GetByValueRelativeRankRange(

      MapReturnType.COUNT, Exp.Val(5), Exp.Val(0), Exp.Val(2), Exp.MapBin("stock")),

    Exp.Val(0)));
```

```javascript
const Aerospike = require('aerospike')

const exp = Aerospike.exp

const maps = Aerospike.maps

const filterExp = exp.gt(

  exp.maps.getByValueRelRankRange(

    exp.binMap('stock'),

    exp.int(2),

    exp.int(0),

    exp.int(5),

    maps.returnType.COUNT,

  ),

  exp.int(0),

)
```

---

#### `map_get_by_rel_rank_range_to_end`

```python
map_get_by_rel_rank_range_to_end(context, result_type, value, rank, bin)
```

Description: [Get](https://aerospike.com/develop/data-types/collections/map/operations#get_by_value_rel_rank_range) all elements at and after **rank** relative to **value**.

Arguments: | Name | Type |
| --- | --- |
| `context` | `library_specific` |
| `result_type` | `integer_value` |
| `value` | `expr` |
| `rank` | `integer_expr` |
| `bin` | `map_bin_expr` |

Introduced: 5.2.0.4

Example: Filter where relative rank selection from value `5` has positive `COUNT`.

-   [Java](#tab-panel-1488)
-   [Python](#tab-panel-1489)
-   [C](#tab-panel-1490)
-   [Go](#tab-panel-1491)
-   [C#](#tab-panel-1492)
-   [Node.js](#tab-panel-1493)

```java
import com.aerospike.client.cdt.MapReturnType;

import com.aerospike.client.exp.Expression;

import com.aerospike.client.exp.Exp;

import com.aerospike.client.exp.MapExp;

Expression exp = Exp.build(

    Exp.gt(

        MapExp.getByValueRelativeRankRange(

            MapReturnType.COUNT, Exp.val(5), Exp.val(0), Exp.mapBin("stock")),

        Exp.val(0)));
```

```python
import aerospike

from aerospike_helpers.expressions import GT, MapBin

from aerospike_helpers.expressions.map import MapGetByValueRelRankRangeToEnd

exp = GT(

    MapGetByValueRelRankRangeToEnd(None, aerospike.MAP_RETURN_COUNT, 5, 0, MapBin("stock")),

    0,

).compile()
```

```c
as_exp_build(predexp,

  as_exp_cmp_gt(

    as_exp_map_get_by_value_rel_rank_range_to_end(

      NULL, AS_MAP_RETURN_COUNT, as_exp_int(5), as_exp_int(0), as_exp_bin_map("stock")),

    as_exp_int(0)));
```

```go
// Requires: import as "github.com/aerospike/aerospike-client-go/v6"

_ = as.ExpGreater(

  as.ExpMapGetByValueRelativeRankRange(

    as.MapReturnType.COUNT,

    as.ExpIntVal(5),

    as.ExpIntVal(0),

    as.ExpMapBin("stock"),

  ),

  as.ExpIntVal(0),

)
```

```csharp
Expression exp = Exp.Build(

  Exp.GT(

    MapExp.GetByValueRelativeRankRange(MapReturnType.COUNT, Exp.Val(5), Exp.Val(0), Exp.MapBin("stock")),

    Exp.Val(0)));
```

```javascript
const Aerospike = require('aerospike')

const exp = Aerospike.exp

const maps = Aerospike.maps

const filterExp = exp.gt(

  exp.maps.getByValueRelRankRangeToEnd(

    exp.binMap('stock'),

    exp.int(0),

    exp.int(5),

    maps.returnType.COUNT,

  ),

  exp.int(0),

)
```

---

#### `map_get_by_value`

```python
map_get_by_value(context, result_type, value, bin)
```

Description: [Get](https://aerospike.com/develop/data-types/collections/map/operations#get_all_by_value) all elements where value == **value**.

Arguments: | Name | Type |
| --- | --- |
| `context` | `library_specific` |
| `result_type` | `integer_value` |
| `value` | `expr` |
| `bin` | `map_bin_expr` |

Introduced: 5.2.0.4

Example: Filter where the count of map entries with value `12` is positive.

-   [Java](#tab-panel-1494)
-   [Python](#tab-panel-1495)
-   [C](#tab-panel-1496)
-   [Go](#tab-panel-1497)
-   [C#](#tab-panel-1498)
-   [Node.js](#tab-panel-1499)

```java
import com.aerospike.client.cdt.MapReturnType;

import com.aerospike.client.exp.Expression;

import com.aerospike.client.exp.Exp;

import com.aerospike.client.exp.MapExp;

Expression exp = Exp.build(

    Exp.gt(MapExp.getByValue(MapReturnType.COUNT, Exp.val(12), Exp.mapBin("stock")), Exp.val(0)));
```

```python
import aerospike

from aerospike_helpers.expressions import GT, MapBin

from aerospike_helpers.expressions.map import MapGetByValue

exp = GT(MapGetByValue(None, aerospike.MAP_RETURN_COUNT, 12, MapBin("stock")), 0).compile()
```

```c
as_exp_build(predexp,

  as_exp_cmp_gt(

    as_exp_map_get_by_value(NULL, AS_MAP_RETURN_COUNT, as_exp_int(12), as_exp_bin_map("stock")),

    as_exp_int(0)));
```

```go
// Requires: import as "github.com/aerospike/aerospike-client-go/v6"

_ = as.ExpGreater(

  as.ExpMapGetByValue(as.MapReturnType.COUNT, as.ExpIntVal(12), as.ExpMapBin("stock")),

  as.ExpIntVal(0),

)
```

```csharp
Expression exp = Exp.Build(

  Exp.GT(MapExp.GetByValue(MapReturnType.COUNT, Exp.Val(12), Exp.MapBin("stock")), Exp.Val(0)));
```

```javascript
const Aerospike = require('aerospike')

const exp = Aerospike.exp

const maps = Aerospike.maps

const filterExp = exp.gt(

  exp.maps.getByValue(exp.binMap('stock'), exp.int(12), maps.returnType.COUNT),

  exp.int(0),

)
```

---

#### `map_get_by_value_list`

```python
map_get_by_value_list(context, result_type, values, bin)
```

Description: [Get](https://aerospike.com/develop/data-types/collections/map/operations#get_all_by_value_list) all elements where value ∈ **values**.

Arguments: | Name | Type |
| --- | --- |
| `context` | `library_specific` |
| `result_type` | `integer_value` |
| `values` | `list_expr` |
| `bin` | `map_bin_expr` |

Introduced: 5.2.0.4

Example: Filter where the count of entries with values `5` and `12` is positive.

-   [Java](#tab-panel-1500)
-   [Python](#tab-panel-1501)
-   [C](#tab-panel-1502)
-   [Go](#tab-panel-1503)
-   [C#](#tab-panel-1504)
-   [Node.js](#tab-panel-1505)

```java
import com.aerospike.client.cdt.MapReturnType;

import com.aerospike.client.exp.Expression;

import com.aerospike.client.exp.Exp;

import com.aerospike.client.exp.MapExp;

import java.util.Arrays;

Expression exp = Exp.build(

    Exp.gt(

        MapExp.getByValueList(MapReturnType.COUNT, Exp.val(Arrays.asList(5, 12)), Exp.mapBin("stock")),

        Exp.val(0)));
```

```python
import aerospike

from aerospike_helpers.expressions import GT, MapBin

from aerospike_helpers.expressions.map import MapGetByValueList

exp = GT(

    MapGetByValueList(None, aerospike.MAP_RETURN_COUNT, [5, 12], MapBin("stock")),

    0,

).compile()
```

```c
as_arraylist vl;

as_arraylist_init(&vl, 2, 2);

as_arraylist_append_int64(&vl, 5);

as_arraylist_append_int64(&vl, 12);

as_exp_build(predexp,

  as_exp_cmp_gt(

    as_exp_map_get_by_value_list(

      NULL, AS_MAP_RETURN_COUNT, as_exp_val(&vl), as_exp_bin_map("stock")),

    as_exp_int(0)));

as_arraylist_destroy(&vl);
```

```go
// Requires: import as "github.com/aerospike/aerospike-client-go/v6"

_ = as.ExpGreater(

  as.ExpMapGetByValueList(

    as.MapReturnType.COUNT,

    as.ExpListVal(as.NewValue(5), as.NewValue(12)),

    as.ExpMapBin("stock"),

  ),

  as.ExpIntVal(0),

)
```

```csharp
using System.Collections.Generic;

Expression exp = Exp.Build(

  Exp.GT(

    MapExp.GetByValueList(MapReturnType.COUNT, Exp.Val(new List<long> { 5, 12 }), Exp.MapBin("stock")),

    Exp.Val(0)));
```

```javascript
const Aerospike = require('aerospike')

const exp = Aerospike.exp

const maps = Aerospike.maps

const filterExp = exp.gt(

  exp.maps.getByValueList(exp.binMap('stock'), exp.list([5, 12]), maps.returnType.COUNT),

  exp.int(0),

)
```

---

#### `map_get_by_value_range`

```python
map_get_by_value_range(context, result_type, start, end, bin)
```

Description: [Get](https://aerospike.com/develop/data-types/collections/map/operations#get_by_value_interval) all elements with value v in interval **start** ≤ v < **end**.

Arguments: | Name | Type |
| --- | --- |
| `context` | `library_specific` |
| `result_type` | `integer_value` |
| `start` | `integer_expr` |
| `end` | `integer_expr` |
| `bin` | `map_bin_expr` |

Introduced: 5.2.0.4

Example: Filter where the count of values in `[5, 50)` in `stock` is positive.

-   [Java](#tab-panel-1506)
-   [Python](#tab-panel-1507)
-   [C](#tab-panel-1508)
-   [Go](#tab-panel-1509)
-   [C#](#tab-panel-1510)
-   [Node.js](#tab-panel-1511)

```java
import com.aerospike.client.cdt.MapReturnType;

import com.aerospike.client.exp.Expression;

import com.aerospike.client.exp.Exp;

import com.aerospike.client.exp.MapExp;

Expression exp = Exp.build(

    Exp.gt(

        MapExp.getByValueRange(MapReturnType.COUNT, Exp.val(5), Exp.val(50), Exp.mapBin("stock")),

        Exp.val(0)));
```

```python
import aerospike

from aerospike_helpers.expressions import GT, MapBin

from aerospike_helpers.expressions.map import MapGetByValueRange

exp = GT(MapGetByValueRange(None, aerospike.MAP_RETURN_COUNT, 5, 50, MapBin("stock")), 0).compile()
```

```c
as_exp_build(predexp,

  as_exp_cmp_gt(

    as_exp_map_get_by_value_range(

      NULL, AS_MAP_RETURN_COUNT, as_exp_int(5), as_exp_int(50), as_exp_bin_map("stock")),

    as_exp_int(0)));
```

```go
// Requires: import as "github.com/aerospike/aerospike-client-go/v6"

_ = as.ExpGreater(

  as.ExpMapGetByValueRange(as.MapReturnType.COUNT, as.ExpIntVal(5), as.ExpIntVal(50), as.ExpMapBin("stock")),

  as.ExpIntVal(0),

)
```

```csharp
Expression exp = Exp.Build(

  Exp.GT(

    MapExp.GetByValueRange(MapReturnType.COUNT, Exp.Val(5), Exp.Val(50), Exp.MapBin("stock")),

    Exp.Val(0)));
```

```javascript
const Aerospike = require('aerospike')

const exp = Aerospike.exp

const maps = Aerospike.maps

const filterExp = exp.gt(

  exp.maps.getByValueRange(exp.binMap('stock'), exp.int(50), exp.int(5), maps.returnType.COUNT),

  exp.int(0),

)
```

---

#### `map_keys`

```python
map_keys(bin)
```

Description: Extract all keys from a map as a list. Unlike the `MapExp` / CDT map read operations, this is a standalone expression (`Exp` class) that takes no `context` or `return_type` parameter.

Arguments: | Name | Type |
| --- | --- |
| `bin` | `map_bin_expr` |

Returns: `list_value`

Introduced: 8.1.2

Example: Get the keys of map bin `stock` as a list, then check its [`list_size`](https://aerospike.com/develop/expressions/list-bin#list_size) is greater than 0.

-   [Java](#tab-panel-1512)
-   [Python](#tab-panel-1513)
-   [C](#tab-panel-1514)
-   [Go](#tab-panel-1515)
-   [C#](#tab-panel-1516)

```java
import com.aerospike.client.exp.Expression;

import com.aerospike.client.exp.Exp;

import com.aerospike.client.exp.ListExp;

Expression exp = Exp.build(

  Exp.gt(

    ListExp.size(Exp.mapKeysIn(Exp.mapBin("stock"))),

    Exp.val(0)));
```

```python
from aerospike_helpers.expressions import GT, MapBin

from aerospike_helpers.expressions.map import MapGetKeys

from aerospike_helpers.expressions.list import ListSize

exp = GT(ListSize(None, MapGetKeys(MapBin("stock"))), 0).compile()
```

```c
as_exp_build(predexp,

  as_exp_cmp_gt(

    as_exp_list_size(NULL, as_exp_map_keys(as_exp_bin_map("stock"))),

    as_exp_int(0)));
```

```go
// Requires: import as "github.com/aerospike/aerospike-client-go/v6"

_ = as.ExpGreater(

  as.ExpListSize(as.ExpMapKeys(as.ExpMapBin("stock"))),

  as.ExpIntVal(0),

)
```

```csharp
Expression exp = Exp.Build(

  Exp.GT(

    ListExp.Size(Exp.MapKeysIn(Exp.MapBin("stock"))),

    Exp.Val(0)));
```

---

#### `map_size`

```python
map_size(context, bin)
```

Description: [Get](https://aerospike.com/develop/data-types/collections/map/operations#size) number of items in the map.

Arguments: | Name | Type |
| --- | --- |
| `context` | `library_specific` |
| `bin` | `map_bin_expr` |

Returns: `integer_bin`

Introduced: 5.2.0.4

Example: Filter records whose map bin `stock` is non-empty (same pattern as [`bin_map`](https://aerospike.com/develop/expressions/storage#bin_map) with `size`).

-   [Java](#tab-panel-1517)
-   [Python](#tab-panel-1518)
-   [C](#tab-panel-1519)
-   [Go](#tab-panel-1520)
-   [C#](#tab-panel-1521)
-   [Node.js](#tab-panel-1522)

```java
import com.aerospike.client.exp.Expression;

import com.aerospike.client.exp.Exp;

import com.aerospike.client.exp.MapExp;

Expression exp = Exp.build(

  Exp.gt(MapExp.size(Exp.mapBin("stock")), Exp.val(0)));
```

```python
from aerospike_helpers.expressions import GT, MapBin

from aerospike_helpers.expressions.map import MapSize

exp = GT(MapSize(None, MapBin("stock")), 0).compile()
```

```c
as_exp_build(predexp,

  as_exp_cmp_gt(

    as_exp_map_size(NULL, as_exp_bin_map("stock")),

    as_exp_int(0)));
```

```go
// Requires: import as "github.com/aerospike/aerospike-client-go/v6"

_ = as.ExpGreater(

  as.ExpMapSize(as.ExpMapBin("stock")),

  as.ExpIntVal(0),

)
```

```csharp
Expression exp = Exp.Build(

  Exp.GT(MapExp.Size(Exp.MapBin("stock")), Exp.Val(0)));
```

```javascript
const Aerospike = require('aerospike')

const exp = Aerospike.exp

const filterExp = exp.gt(

  exp.maps.size(exp.binMap('stock')),

  exp.int(0),

)
```

---

#### `map_values`

```python
map_values(bin)
```

Description: Extract all values from a map as a list. Unlike the `MapExp` / CDT map read operations, this is a standalone expression (`Exp` class) that takes no `context` or `return_type` parameter.

Arguments: | Name | Type |
| --- | --- |
| `bin` | `map_bin_expr` |

Returns: `list_value`

Introduced: 8.1.2

Example: Get the values of map bin `stock` as a list, then check its [`list_size`](https://aerospike.com/develop/expressions/list-bin#list_size) is greater than 0.

-   [Java](#tab-panel-1523)
-   [Python](#tab-panel-1524)
-   [C](#tab-panel-1525)
-   [Go](#tab-panel-1526)
-   [C#](#tab-panel-1527)

```java
import com.aerospike.client.exp.Expression;

import com.aerospike.client.exp.Exp;

import com.aerospike.client.exp.ListExp;

Expression exp = Exp.build(

  Exp.gt(

    ListExp.size(Exp.mapValuesIn(Exp.mapBin("stock"))),

    Exp.val(0)));
```

```python
from aerospike_helpers.expressions import GT, MapBin

from aerospike_helpers.expressions.map import MapGetValues

from aerospike_helpers.expressions.list import ListSize

exp = GT(ListSize(None, MapGetValues(MapBin("stock"))), 0).compile()
```

```c
as_exp_build(predexp,

  as_exp_cmp_gt(

    as_exp_list_size(NULL, as_exp_map_values(as_exp_bin_map("stock"))),

    as_exp_int(0)));
```

```go
// Requires: import as "github.com/aerospike/aerospike-client-go/v6"

_ = as.ExpGreater(

  as.ExpListSize(as.ExpMapValues(as.ExpMapBin("stock"))),

  as.ExpIntVal(0),

)
```

```csharp
Expression exp = Exp.Build(

  Exp.GT(

    ListExp.Size(Exp.MapValuesIn(Exp.MapBin("stock"))),

    Exp.Val(0)));
```

---