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

# Map expressions

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

Map expressions read and modify map values inside an [expression](https://aerospike.com/docs/develop/expressions/) tree. For the data type itself and its Operate API, see [Map](https://aerospike.com/docs/develop/data-types/collections/map).

Read expressions (`map_size`, `map_get_by_key`, `map_get_by_value`, the index, rank and range variants) evaluate to whatever `result_type` selects — a count, an index, a rank, a key, or a value. That makes them **projection**: they shape what a command returns for each record, in [`operate`](https://aerospike.com/docs/develop/learn/bin-operations/), in a [batch](https://aerospike.com/docs/develop/learn/batch/), and in a [query](https://aerospike.com/docs/develop/learn/queries/projection). Wrap one in [comparison](https://aerospike.com/docs/develop/expressions/comparison) or [logic](https://aerospike.com/docs/develop/expressions/logic) to get the Boolean a record filter needs.

Modify expressions (`map_put`, `map_put_items`, `map_increment`, `map_clear`, the `map_remove_by_*` variants) evaluate to a new map and leave the record untouched. Storing that value takes a write operation expression; see [Operations and expressions](https://aerospike.com/docs/develop/learn/operations-and-expressions) for how the two APIs differ.

A map operand is a bin, read with [`bin_map`](https://aerospike.com/docs/develop/expressions/storage#bin_map), or any expression that evaluates to a map. Reading stored data can evaluate to `unknown`; see [Unknown results](https://aerospike.com/docs/develop/expressions#unknown-results).

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/).

The Developer SDK’s [AEL](https://aerospike.com/docs/develop/client/sdk/concepts/ael/reference) text syntax expresses the same map operations as path functions, for example `$.profile.name.setTo('Alice')`.

## Composing expressions

An expression evaluates to a value, and that value is what the next expression operates on — see [Expressions compose](https://aerospike.com/docs/develop/expressions#expressions-compose).

Every map operation takes its `bin` operand that way: not only a named map bin, but the result of any expression evaluating to a map. [`map_put`](#map_put) shows the pattern — its example takes the [`map_size`](#map_size) of the map after the put, so the size counts the new entry while the record keeps the original.

## Extraction helpers

[`map_keys`](#map_keys) and [`map_values`](#map_values) (Database 8.1.2 and later) are standalone readers: they take a map operand and nothing else, evaluating to a list of the map’s keys or of its values. Alone among the map reads they take neither a `context` nor a `result_type`, because there is only one thing each can return.

Use them to turn a map into a list that the rest of the expression tree can work on — testing membership with [`in_list`](https://aerospike.com/docs/develop/expressions/comparison#in_list), for instance, or counting with [`list_size`](https://aerospike.com/docs/develop/expressions/list#list_size).

A difference from the CDT Map API

A map modify expression evaluates to the whole modified map. The matching [CDT Map operation](https://aerospike.com/docs/develop/data-types/collections/map/operations) returns something narrower and operation-specific: `put` returns the new entry count, and the remove-by operations return what `result_type` selects.

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](https://aerospike.com/docs/develop/client/sdk/concepts/ael/reference) for AEL grammar.

## Modify

#### `map_clear`

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

Description: Returns the map with all elements removed.

Arguments: | Name | Type | Description |
| --- | --- | --- |
| `context` | `Context instance` | 
Optional [context path](https://aerospike.com/docs/develop/data-types/collections/context) selecting a List or Map nested inside the operand. Omit it to operate on the top level.

 |
| `bin` | `map` | 

Map bin to operate on, or any expression that evaluates to a map.

 |

Returns: `map`

Introduced: 5.2.0.4

Operate API operation: [`clear`](https://aerospike.com/docs/develop/data-types/collections/map/operations#clear)

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

-   [Java SDK](#tab-panel-1777)
-   [Python SDK](#tab-panel-1778)
-   [Rust](#tab-panel-1779)
-   [C#](#tab-panel-1780)
-   [Go](#tab-panel-1781)
-   [Node.js](#tab-panel-1782)
-   [C](#tab-panel-1783)
-   [Java](#tab-panel-1784)
-   [Python](#tab-panel-1785)

```java
String exp = "$.stock:MAP.clear().count() == 0";
```

```python
exp = "$.stock:MAP.clear().count() == 0"
```

```rust
use aerospike::expressions::maps as map_exp;

use aerospike::expressions::{eq, int_val, map_bin};

let exp = eq(map_exp::size(map_exp::clear(map_bin("stock".into()), &[]), &[]), int_val(0));
```

```csharp
Expression exp = Exp.Build(

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

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

exp := as.ExpEq(as.ExpMapSize(as.ExpMapClear(as.ExpMapBin("stock"))), as.ExpIntVal(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))
```

```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)));
```

```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()
```

---

#### `map_increment`

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

Description: Returns the map with the value at `key` increased by `delta`.

Arguments: | Name | Type | Description |
| --- | --- | --- |
| `context` | `Context instance` | 
Optional [context path](https://aerospike.com/docs/develop/data-types/collections/context) selecting a List or Map nested inside the operand. Omit it to operate on the top level.

 |
| `policy` | `Map policy` | 

Write flags for the operation. See [Write flags](https://aerospike.com/docs/develop/data-types/collections/map/operations#write-flags). A violated flag fails the expression, unless `no_fail` is set, in which case the map comes back unchanged. The policy’s ordering attribute has no effect here: order is fixed when a map is created, and an expression never creates one.

 |
| `key` | `any` | 

Map key the operation applies to.

 |
| `delta` | `integer or float` | 

Amount to add to the value stored under `key`. A negative value subtracts. The stored value’s own type governs: a float added to an integer is truncated toward zero first, so adding `1.5` adds `1` and adding `0.5` leaves it unchanged.

 |
| `bin` | `map` | 

Map bin to operate on, or any expression that evaluates to a map.

 |

Returns: `map`

Introduced: 5.2.0.4

Operate API operation: [`increment`](https://aerospike.com/docs/develop/data-types/collections/map/operations#increment)

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

-   [Java SDK](#tab-panel-1786)
-   [Python SDK](#tab-panel-1787)
-   [Rust](#tab-panel-1788)
-   [C#](#tab-panel-1789)
-   [Go](#tab-panel-1790)
-   [Node.js](#tab-panel-1791)
-   [C](#tab-panel-1792)
-   [Java](#tab-panel-1793)
-   [Python](#tab-panel-1794)

```java
String exp = "($.stock.'sku-a'.add(5)).'sku-a' == 100";
```

```python
exp = "($.stock.'sku-a'.add(5)).'sku-a' == 100"
```

```rust
use aerospike::expressions::maps as map_exp;

use aerospike::expressions::{ExpType, eq, int_val, map_bin, string_val};

use aerospike::{MapPolicy, MapReturnType};

let exp = eq(

    map_exp::get_by_key(

        MapReturnType::Value,

        ExpType::INT,

        string_val("sku-a".into()),

        map_exp::increment(

            &MapPolicy::default(),

            string_val("sku-a".into()),

            int_val(5),

            map_bin("stock".into()),

            &[]),

        &[]),

    int_val(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)));
```

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

exp := 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),

)
```

```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),

)
```

```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)));
```

```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()
```

---

#### `map_put`

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

Description: Returns the map with `value` stored at `key`. It does not create a bin that does not exist, unlike the [`put`](https://aerospike.com/docs/develop/data-types/collections/map/operations#put) CDT Map operation, which does.

Arguments: | Name | Type | Description |
| --- | --- | --- |
| `context` | `Context instance` | 
Optional [context path](https://aerospike.com/docs/develop/data-types/collections/context) selecting a List or Map nested inside the operand. Omit it to operate on the top level.

 |
| `policy` | `Map policy` | 

Write flags for the operation. See [Write flags](https://aerospike.com/docs/develop/data-types/collections/map/operations#write-flags). A violated flag fails the expression, unless `no_fail` is set, in which case the map comes back unchanged. The policy’s ordering attribute has no effect here: order is fixed when a map is created, and an expression never creates one.

 |
| `key` | `any` | 

Map key the operation applies to.

 |
| `value` | `any` | 

Value to store under `key`, replacing any value already there.

 |
| `bin` | `map` | 

Map bin to operate on, or any expression that evaluates to a map.

 |

Returns: `map`

Introduced: 5.2.0.4

Operate API operation: [`put`](https://aerospike.com/docs/develop/data-types/collections/map/operations#put)

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

-   [Java SDK](#tab-panel-1795)
-   [Python SDK](#tab-panel-1796)
-   [Rust](#tab-panel-1797)
-   [C#](#tab-panel-1798)
-   [Go](#tab-panel-1799)
-   [Node.js](#tab-panel-1800)
-   [C](#tab-panel-1801)
-   [Java](#tab-panel-1802)
-   [Python](#tab-panel-1803)

```java
String exp = "$.stock.'sku-a'.setTo(12).count() > 2";
```

```python
exp = "$.stock.'sku-a'.setTo(12).count() > 2"
```

```rust
use aerospike::expressions::maps as map_exp;

use aerospike::expressions::{gt, int_val, map_bin, string_val};

use aerospike::MapPolicy;

let exp = gt(

    map_exp::size(

        map_exp::put(

            &MapPolicy::default(),

            string_val("sku-a".into()),

            int_val(12),

            map_bin("stock".into()),

            &[]),

        &[]),

    int_val(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)));
```

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

exp := as.ExpGreater(

  as.ExpMapSize(

    as.ExpMapPut(

      as.DefaultMapPolicy(),

      as.ExpStringVal("sku-a"),

      as.ExpIntVal(12),

      as.ExpMapBin("stock"),

    ),

  ),

  as.ExpIntVal(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),

)
```

```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)));
```

```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()
```

---

#### `map_put_items`

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

Description: Returns the map with every entry of `items` added. It does not create a bin that does not exist, unlike the [`put_items`](https://aerospike.com/docs/develop/data-types/collections/map/operations#put_items) CDT Map operation, which does.

Arguments: | Name | Type | Description |
| --- | --- | --- |
| `context` | `Context instance` | 
Optional [context path](https://aerospike.com/docs/develop/data-types/collections/context) selecting a List or Map nested inside the operand. Omit it to operate on the top level.

 |
| `policy` | `Map policy` | 

Write flags for the operation. See [Write flags](https://aerospike.com/docs/develop/data-types/collections/map/operations#write-flags). A violated flag fails the expression, unless `no_fail` is set, in which case the map comes back unchanged. The policy’s ordering attribute has no effect here: order is fixed when a map is created, and an expression never creates one.

 |
| `items` | `map` | 

Key/value pairs to write, as a map. A key already present is overwritten; a key that is absent is added.

 |
| `bin` | `map` | 

Map bin to operate on, or any expression that evaluates to a map.

 |

Returns: `map`

Introduced: 5.2.0.4

Operate API operation: [`put_items`](https://aerospike.com/docs/develop/data-types/collections/map/operations#put_items)

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

-   [Java SDK](#tab-panel-1804)
-   [Python SDK](#tab-panel-1805)
-   [Rust](#tab-panel-1806)
-   [C#](#tab-panel-1807)
-   [Go](#tab-panel-1808)
-   [Node.js](#tab-panel-1809)
-   [C](#tab-panel-1810)
-   [Java](#tab-panel-1811)
-   [Python](#tab-panel-1812)

```java
String exp = "$.stock.putItems({'sku-b': 2, 'sku-c': 3}).count() > 3";
```

```python
exp = "$.stock.putItems({'sku-b': 2, 'sku-c': 3}).count() > 3"
```

```rust
use aerospike::expressions::maps as map_exp;

use aerospike::expressions::{gt, int_val, map_bin, map_val};

use aerospike::{MapPolicy, Value};

use std::collections::HashMap;

let items = HashMap::from([

    (Value::from("sku-b"), Value::from(2)),

    (Value::from("sku-c"), Value::from(3)),

]);

let exp = gt(

    map_exp::size(

        map_exp::put_items(

            &MapPolicy::default(),

            map_val(items),

            map_bin("stock".into()),

            &[]),

        &[]),

    int_val(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 } }, MapOrder.UNORDERED),

        Exp.MapBin("stock"))),

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

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

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

exp := as.ExpGreater(

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

  as.ExpIntVal(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),

)
```

```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);
```

```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()
```

---

#### `map_remove_by_index`

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

Description: Returns the map with the element at `index` removed.

Arguments: | Name | Type | Description |
| --- | --- | --- |
| `context` | `Context instance` | 
Optional [context path](https://aerospike.com/docs/develop/data-types/collections/context) selecting a List or Map nested inside the operand. Omit it to operate on the top level.

 |
| `index` | `integer` | 

Zero-based position in the collection, 0 being the first element. A negative index counts back from the end.

 |
| `bin` | `map` | 

Map bin to operate on, or any expression that evaluates to a map.

 |

Returns: `map`

Introduced: 5.2.0.4

Operate API operation: [`remove_by_index`](https://aerospike.com/docs/develop/data-types/collections/map/operations#remove_by_index)

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

-   [Java SDK](#tab-panel-1813)
-   [Python SDK](#tab-panel-1814)
-   [Rust](#tab-panel-1815)
-   [C#](#tab-panel-1816)
-   [Go](#tab-panel-1817)
-   [Node.js](#tab-panel-1818)
-   [C](#tab-panel-1819)
-   [Java](#tab-panel-1820)
-   [Python](#tab-panel-1821)

```java
String exp = "$.stock.{0}.remove().count() > 0";
```

```python
exp = "$.stock.{0}.remove().count() > 0"
```

```rust
use aerospike::expressions::maps as map_exp;

use aerospike::expressions::{gt, int_val, map_bin};

use aerospike::MapReturnType;

let exp = gt(

    map_exp::size(

        map_exp::remove_by_index(

            MapReturnType::None,

            int_val(0),

            map_bin("stock".into()),

            &[]),

        &[]),

    int_val(0));
```

```csharp
Expression exp = Exp.Build(

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

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

exp := as.ExpGreater(

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

  as.ExpIntVal(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),

)
```

```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)));
```

```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()
```

---

#### `map_remove_by_index_range`

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

Description: Returns the map with `count` elements removed, starting at `index`.

Arguments: | Name | Type | Description |
| --- | --- | --- |
| `context` | `Context instance` | 
Optional [context path](https://aerospike.com/docs/develop/data-types/collections/context) selecting a List or Map nested inside the operand. Omit it to operate on the top level.

 |
| `index` | `integer` | 

Zero-based position in the collection, 0 being the first element. A negative index counts back from the end.

 |
| `count` | `integer` | 

Number of elements in the range.

 |
| `bin` | `map` | 

Map bin to operate on, or any expression that evaluates to a map.

 |

Returns: `map`

Introduced: 5.2.0.4

Operate API operation: [`remove_by_index_range`](https://aerospike.com/docs/develop/data-types/collections/map/operations#remove_by_index_range)

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

-   [Java SDK](#tab-panel-1822)
-   [Python SDK](#tab-panel-1823)
-   [Rust](#tab-panel-1824)
-   [C#](#tab-panel-1825)
-   [Go](#tab-panel-1826)
-   [Node.js](#tab-panel-1827)
-   [C](#tab-panel-1828)
-   [Java](#tab-panel-1829)
-   [Python](#tab-panel-1830)

```java
String exp = "$.stock.{0:1}.remove().count() > 0";
```

```python
exp = "$.stock.{0:1}.remove().count() > 0"
```

```rust
use aerospike::expressions::maps as map_exp;

use aerospike::expressions::{gt, int_val, map_bin};

use aerospike::MapReturnType;

let exp = gt(

    map_exp::size(

        map_exp::remove_by_index_range_count(

            MapReturnType::None,

            int_val(0),

            int_val(1),

            map_bin("stock".into()),

            &[]),

        &[]),

    int_val(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)));
```

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

exp := as.ExpGreater(

  as.ExpMapSize(

    as.ExpMapRemoveByIndexRangeCount(

      as.MapReturnType.NONE,

      as.ExpIntVal(0),

      as.ExpIntVal(1),

      as.ExpMapBin("stock"),

    ),

  ),

  as.ExpIntVal(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),

)
```

```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)));
```

```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()
```

---

#### `map_remove_by_index_range_to_end`

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

Description: Returns the map with every element from `index` to the end removed.

Arguments: | Name | Type | Description |
| --- | --- | --- |
| `context` | `Context instance` | 
Optional [context path](https://aerospike.com/docs/develop/data-types/collections/context) selecting a List or Map nested inside the operand. Omit it to operate on the top level.

 |
| `index` | `integer` | 

Zero-based position in the collection, 0 being the first element. A negative index counts back from the end.

 |
| `bin` | `map` | 

Map bin to operate on, or any expression that evaluates to a map.

 |

Returns: `map`

Introduced: 5.2.0.4

Operate API operation: [`remove_by_index_range`](https://aerospike.com/docs/develop/data-types/collections/map/operations#remove_by_index_range)

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

-   [Java SDK](#tab-panel-1831)
-   [Python SDK](#tab-panel-1832)
-   [Rust](#tab-panel-1833)
-   [C#](#tab-panel-1834)
-   [Go](#tab-panel-1835)
-   [Node.js](#tab-panel-1836)
-   [C](#tab-panel-1837)
-   [Java](#tab-panel-1838)
-   [Python](#tab-panel-1839)

```java
String exp = "$.stock.{1:}.remove().count() > 0";
```

```python
exp = "$.stock.{1:}.remove().count() > 0"
```

```rust
use aerospike::expressions::maps as map_exp;

use aerospike::expressions::{gt, int_val, map_bin};

use aerospike::MapReturnType;

let exp = gt(

    map_exp::size(

        map_exp::remove_by_index_range(

            MapReturnType::None,

            int_val(1),

            map_bin("stock".into()),

            &[]),

        &[]),

    int_val(0));
```

```csharp
Expression exp = Exp.Build(

  Exp.GT(

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

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

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

exp := as.ExpGreater(

  as.ExpMapSize(

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

  ),

  as.ExpIntVal(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),

)
```

```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)));
```

```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()
```

---

#### `map_remove_by_key`

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

Description: Returns the map with the element at `key` removed.

Arguments: | Name | Type | Description |
| --- | --- | --- |
| `context` | `Context instance` | 
Optional [context path](https://aerospike.com/docs/develop/data-types/collections/context) selecting a List or Map nested inside the operand. Omit it to operate on the top level.

 |
| `key` | `any` | 

Map key the operation applies to.

 |
| `bin` | `map` | 

Map bin to operate on, or any expression that evaluates to a map.

 |

Returns: `map`

Introduced: 5.2.0.4

Operate API operation: [`remove_by_key`](https://aerospike.com/docs/develop/data-types/collections/map/operations#remove_by_key)

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

-   [Java SDK](#tab-panel-1840)
-   [Python SDK](#tab-panel-1841)
-   [Rust](#tab-panel-1842)
-   [C#](#tab-panel-1843)
-   [Go](#tab-panel-1844)
-   [Node.js](#tab-panel-1845)
-   [C](#tab-panel-1846)
-   [Java](#tab-panel-1847)
-   [Python](#tab-panel-1848)

```java
String exp = "$.stock.'sku-a'.remove().count() == 2";
```

```python
exp = "$.stock.'sku-a'.remove().count() == 2"
```

```rust
use aerospike::expressions::maps as map_exp;

use aerospike::expressions::{eq, int_val, map_bin, string_val};

use aerospike::MapReturnType;

let exp = eq(

    map_exp::size(

        map_exp::remove_by_key(

            MapReturnType::None,

            string_val("sku-a".into()),

            map_bin("stock".into()),

            &[]),

        &[]),

    int_val(2));
```

```csharp
Expression exp = Exp.Build(

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

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

exp := as.ExpEq(

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

  as.ExpIntVal(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))
```

```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)));
```

```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()
```

---

#### `map_remove_by_key_list`

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

Description: Returns the map with every element whose key is in `keys` removed.

Arguments: | Name | Type | Description |
| --- | --- | --- |
| `context` | `Context instance` | 
Optional [context path](https://aerospike.com/docs/develop/data-types/collections/context) selecting a List or Map nested inside the operand. Omit it to operate on the top level.

 |
| `keys` | `list` | 

Keys to match, as a list. Every entry whose key appears in it is removed.

 |
| `bin` | `map` | 

Map bin to operate on, or any expression that evaluates to a map.

 |

Returns: `map`

Introduced: 5.2.0.4

Operate API operation: [`remove_all_by_key_list`](https://aerospike.com/docs/develop/data-types/collections/map/operations#remove_all_by_key_list)

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

-   [Java SDK](#tab-panel-1849)
-   [Python SDK](#tab-panel-1850)
-   [Rust](#tab-panel-1851)
-   [C#](#tab-panel-1852)
-   [Go](#tab-panel-1853)
-   [Node.js](#tab-panel-1854)
-   [C](#tab-panel-1855)
-   [Java](#tab-panel-1856)
-   [Python](#tab-panel-1857)

```java
String exp = "$.stock.{@'sku-a', 'sku-b'}.remove().count() == 1";
```

```python
exp = "$.stock.{@'sku-a', 'sku-b'}.remove().count() == 1"
```

```rust
use aerospike::expressions::maps as map_exp;

use aerospike::expressions::{eq, int_val, list_val, map_bin};

use aerospike::{MapReturnType, Value};

let exp = eq(

    map_exp::size(

        map_exp::remove_by_key_list(

            MapReturnType::None,

            list_val(vec![Value::from("sku-a"), Value::from("sku-b")]),

            map_bin("stock".into()),

            &[]),

        &[]),

    int_val(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)));
```

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

exp := 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),

)
```

```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),

)
```

```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);
```

```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()
```

---

#### `map_remove_by_key_range`

```python
map_remove_by_key_range(context, key_begin, key_end, bin)
```

Description: Returns the map with every element whose key is in the interval `key_begin` ≤ k < `key_end` removed.

Arguments: | Name | Type | Description |
| --- | --- | --- |
| `context` | `Context instance` | 
Optional [context path](https://aerospike.com/docs/develop/data-types/collections/context) selecting a List or Map nested inside the operand. Omit it to operate on the top level.

 |
| `key_begin` | `any` | 

Lowest key to match, inclusive.

 |
| `key_end` | `any` | 

Upper bound on the key, exclusive. Omit it to match everything from `key_begin` upward.

 |
| `bin` | `map` | 

Map bin to operate on, or any expression that evaluates to a map.

 |

Returns: `map`

Introduced: 5.2.0.4

Operate API operation: [`remove_by_key_interval`](https://aerospike.com/docs/develop/data-types/collections/map/operations#remove_by_key_interval)

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

-   [Java SDK](#tab-panel-1858)
-   [Python SDK](#tab-panel-1859)
-   [Rust](#tab-panel-1860)
-   [C#](#tab-panel-1861)
-   [Go](#tab-panel-1862)
-   [Node.js](#tab-panel-1863)
-   [C](#tab-panel-1864)
-   [Java](#tab-panel-1865)
-   [Python](#tab-panel-1866)

```java
String exp = "$.stock.{@'sku-a':'sku-z'}.remove().count() > 0";
```

```python
exp = "$.stock.{@'sku-a':'sku-z'}.remove().count() > 0"
```

```rust
use aerospike::expressions::maps as map_exp;

use aerospike::expressions::{gt, int_val, map_bin, string_val};

use aerospike::MapReturnType;

let exp = gt(

    map_exp::size(

        map_exp::remove_by_key_range(

            MapReturnType::None,

            Some(string_val("sku-a".into())),

            Some(string_val("sku-z".into())),

            map_bin("stock".into()),

            &[]),

        &[]),

    int_val(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)));
```

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

exp := as.ExpGreater(

  as.ExpMapSize(

    as.ExpMapRemoveByKeyRange(

      as.MapReturnType.NONE,

      as.ExpStringVal("sku-a"),

      as.ExpStringVal("sku-z"),

      as.ExpMapBin("stock"),

    ),

  ),

  as.ExpIntVal(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),

)
```

```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)));
```

```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()
```

---

#### `map_remove_by_rank`

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

Description: Returns the map with the element of rank `rank` removed.

Arguments: | Name | Type | Description |
| --- | --- | --- |
| `context` | `Context instance` | 
Optional [context path](https://aerospike.com/docs/develop/data-types/collections/context) selecting a List or Map nested inside the operand. Omit it to operate on the top level.

 |
| `rank` | `integer` | 

Rank of the element in value order, 0 being the smallest. A negative rank counts back from the largest.

 |
| `bin` | `map` | 

Map bin to operate on, or any expression that evaluates to a map.

 |

Returns: `map`

Introduced: 5.2.0.4

Operate API operation: [`remove_by_rank`](https://aerospike.com/docs/develop/data-types/collections/map/operations#remove_by_rank)

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

-   [Java SDK](#tab-panel-1867)
-   [Python SDK](#tab-panel-1868)
-   [Rust](#tab-panel-1869)
-   [C#](#tab-panel-1870)
-   [Go](#tab-panel-1871)
-   [Node.js](#tab-panel-1872)
-   [C](#tab-panel-1873)
-   [Java](#tab-panel-1874)
-   [Python](#tab-panel-1875)

```java
String exp = "$.stock.{#0}.remove().count() > 0";
```

```python
exp = "$.stock.{#0}.remove().count() > 0"
```

```rust
use aerospike::expressions::maps as map_exp;

use aerospike::expressions::{gt, int_val, map_bin};

use aerospike::MapReturnType;

let exp = gt(

    map_exp::size(

        map_exp::remove_by_rank(

            MapReturnType::None,

            int_val(0),

            map_bin("stock".into()),

            &[]),

        &[]),

    int_val(0));
```

```csharp
Expression exp = Exp.Build(

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

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

exp := as.ExpGreater(

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

  as.ExpIntVal(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),

)
```

```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)));
```

```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()
```

---

#### `map_remove_by_rank_range`

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

Description: Returns the map with `count` elements removed, starting at rank `rank`.

Arguments: | Name | Type | Description |
| --- | --- | --- |
| `context` | `Context instance` | 
Optional [context path](https://aerospike.com/docs/develop/data-types/collections/context) selecting a List or Map nested inside the operand. Omit it to operate on the top level.

 |
| `rank` | `integer` | 

Rank of the element in value order, 0 being the smallest. A negative rank counts back from the largest.

 |
| `count` | `integer` | 

Number of elements in the range.

 |
| `bin` | `map` | 

Map bin to operate on, or any expression that evaluates to a map.

 |

Returns: `map`

Introduced: 5.2.0.4

Operate API operation: [`remove_by_rank_range`](https://aerospike.com/docs/develop/data-types/collections/map/operations#remove_by_rank_range)

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

-   [Java SDK](#tab-panel-1876)
-   [Python SDK](#tab-panel-1877)
-   [Rust](#tab-panel-1878)
-   [C#](#tab-panel-1879)
-   [Go](#tab-panel-1880)
-   [Node.js](#tab-panel-1881)
-   [C](#tab-panel-1882)
-   [Java](#tab-panel-1883)
-   [Python](#tab-panel-1884)

```java
String exp = "$.stock.{#0:2}.remove().count() > 0";
```

```python
exp = "$.stock.{#0:2}.remove().count() > 0"
```

```rust
use aerospike::expressions::maps as map_exp;

use aerospike::expressions::{gt, int_val, map_bin};

use aerospike::MapReturnType;

let exp = gt(

    map_exp::size(

        map_exp::remove_by_rank_range_count(

            MapReturnType::None,

            int_val(0),

            int_val(2),

            map_bin("stock".into()),

            &[]),

        &[]),

    int_val(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)));
```

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

exp := as.ExpGreater(

  as.ExpMapSize(

    as.ExpMapRemoveByRankRangeCount(

      as.MapReturnType.NONE,

      as.ExpIntVal(0),

      as.ExpIntVal(2),

      as.ExpMapBin("stock"),

    ),

  ),

  as.ExpIntVal(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),

)
```

```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)));
```

```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()
```

---

#### `map_remove_by_rank_range_to_end`

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

Description: Returns the map with every element of rank `rank` or higher removed.

Arguments: | Name | Type | Description |
| --- | --- | --- |
| `context` | `Context instance` | 
Optional [context path](https://aerospike.com/docs/develop/data-types/collections/context) selecting a List or Map nested inside the operand. Omit it to operate on the top level.

 |
| `rank` | `integer` | 

Rank of the element in value order, 0 being the smallest. A negative rank counts back from the largest.

 |
| `bin` | `map` | 

Map bin to operate on, or any expression that evaluates to a map.

 |

Returns: `map`

Introduced: 5.2.0.4

Operate API operation: [`remove_by_rank_range`](https://aerospike.com/docs/develop/data-types/collections/map/operations#remove_by_rank_range)

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

-   [Java SDK](#tab-panel-1885)
-   [Python SDK](#tab-panel-1886)
-   [Rust](#tab-panel-1887)
-   [C#](#tab-panel-1888)
-   [Go](#tab-panel-1889)
-   [Node.js](#tab-panel-1890)
-   [C](#tab-panel-1891)
-   [Java](#tab-panel-1892)
-   [Python](#tab-panel-1893)

```java
String exp = "$.stock.{#1:}.remove().count() > 0";
```

```python
exp = "$.stock.{#1:}.remove().count() > 0"
```

```rust
use aerospike::expressions::maps as map_exp;

use aerospike::expressions::{gt, int_val, map_bin};

use aerospike::MapReturnType;

let exp = gt(

    map_exp::size(

        map_exp::remove_by_rank_range(

            MapReturnType::None,

            int_val(1),

            map_bin("stock".into()),

            &[]),

        &[]),

    int_val(0));
```

```csharp
Expression exp = Exp.Build(

  Exp.GT(

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

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

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

exp := as.ExpGreater(

  as.ExpMapSize(

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

  ),

  as.ExpIntVal(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(1), null, maps.returnType.NONE),

  ),

  exp.int(0),

)
```

```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(1), as_exp_bin_map("stock"))),

    as_exp_int(0)));
```

```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(1), 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, 1, MapBin("stock"))), 0).compile()
```

---

#### `map_remove_by_rel_index_range`

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

Description: Returns the map with `count` elements removed, starting at the index `index` places from `key`.

Arguments: | Name | Type | Description |
| --- | --- | --- |
| `context` | `Context instance` | 
Optional [context path](https://aerospike.com/docs/develop/data-types/collections/context) selecting a List or Map nested inside the operand. Omit it to operate on the top level.

 |
| `key` | `any` | 

Map key the operation applies to.

 |
| `index` | `integer` | 

Zero-based position in the collection, 0 being the first element. A negative index counts back from the end.

 |
| `count` | `integer` | 

Number of elements in the range.

 |
| `bin` | `map` | 

Map bin to operate on, or any expression that evaluates to a map.

 |

Returns: `map`

Introduced: 5.2.0.4

Operate API operation: [`remove_by_key_rel_index_range`](https://aerospike.com/docs/develop/data-types/collections/map/operations#remove_by_key_rel_index_range)

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

-   [Java SDK](#tab-panel-1894)
-   [Python SDK](#tab-panel-1895)
-   [Rust](#tab-panel-1896)
-   [C#](#tab-panel-1897)
-   [Go](#tab-panel-1898)
-   [Node.js](#tab-panel-1899)
-   [C](#tab-panel-1900)
-   [Java](#tab-panel-1901)
-   [Python](#tab-panel-1902)

```java
String exp = "$.stock.{0:0~'sku-a'}.remove().count() > 0";
```

```python
exp = "$.stock.{0:0~'sku-a'}.remove().count() > 0"
```

```rust
use aerospike::expressions::maps as map_exp;

use aerospike::expressions::{gt, int_val, map_bin, string_val};

use aerospike::MapReturnType;

let exp = gt(

    map_exp::size(

        map_exp::remove_by_key_relative_index_range_count(

            MapReturnType::None,

            string_val("sku-a".into()),

            int_val(0),

            int_val(1),

            map_bin("stock".into()),

            &[]),

        &[]),

    int_val(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)));
```

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

exp := 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),

)
```

```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),

)
```

```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)));
```

```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()
```

---

#### `map_remove_by_rel_index_range_to_end`

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

Description: Returns the map with every element from the index `index` places from `key` to the end removed.

Arguments: | Name | Type | Description |
| --- | --- | --- |
| `context` | `Context instance` | 
Optional [context path](https://aerospike.com/docs/develop/data-types/collections/context) selecting a List or Map nested inside the operand. Omit it to operate on the top level.

 |
| `key` | `any` | 

Map key the operation applies to.

 |
| `index` | `integer` | 

Zero-based position in the collection, 0 being the first element. A negative index counts back from the end.

 |
| `bin` | `map` | 

Map bin to operate on, or any expression that evaluates to a map.

 |

Returns: `map`

Introduced: 5.2.0.4

Operate API operation: [`remove_by_key_rel_index_range`](https://aerospike.com/docs/develop/data-types/collections/map/operations#remove_by_key_rel_index_range)

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

-   [Java SDK](#tab-panel-1903)
-   [Python SDK](#tab-panel-1904)
-   [Rust](#tab-panel-1905)
-   [C#](#tab-panel-1906)
-   [Go](#tab-panel-1907)
-   [Node.js](#tab-panel-1908)
-   [C](#tab-panel-1909)
-   [Java](#tab-panel-1910)
-   [Python](#tab-panel-1911)

```java
String exp = "$.stock.{0:~'sku-a'}.remove().count() > 0";
```

```python
exp = "$.stock.{0:~'sku-a'}.remove().count() > 0"
```

```rust
use aerospike::expressions::maps as map_exp;

use aerospike::expressions::{gt, int_val, map_bin, string_val};

use aerospike::MapReturnType;

let exp = gt(

    map_exp::size(

        map_exp::remove_by_key_relative_index_range(

            MapReturnType::None,

            string_val("sku-a".into()),

            int_val(0),

            map_bin("stock".into()),

            &[]),

        &[]),

    int_val(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)));
```

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

exp := as.ExpGreater(

  as.ExpMapSize(

    as.ExpMapRemoveByKeyRelativeIndexRange(

      as.MapReturnType.NONE,

      as.ExpStringVal("sku-a"),

      as.ExpIntVal(0),

      as.ExpMapBin("stock"),

    ),

  ),

  as.ExpIntVal(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),

)
```

```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)));
```

```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()
```

---

#### `map_remove_by_rel_rank_range`

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

Description: Returns the map with `count` elements removed, starting at the rank `rank` places from `value`.

Arguments: | Name | Type | Description |
| --- | --- | --- |
| `context` | `Context instance` | 
Optional [context path](https://aerospike.com/docs/develop/data-types/collections/context) selecting a List or Map nested inside the operand. Omit it to operate on the top level.

 |
| `value` | `any` | 

Value that `rank` is measured from. It need not be present in the collection — the rank is taken from where it would sort.

 |
| `rank` | `integer` | 

Rank of the element in value order, 0 being the smallest. A negative rank counts back from the largest.

 |
| `count` | `integer` | 

Number of elements in the range.

 |
| `bin` | `map` | 

Map bin to operate on, or any expression that evaluates to a map.

 |

Returns: `map`

Introduced: 5.2.0.4

Operate API operation: [`remove_by_value_rel_rank_range`](https://aerospike.com/docs/develop/data-types/collections/map/operations#remove_by_value_rel_rank_range)

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

-   [Java SDK](#tab-panel-1912)
-   [Python SDK](#tab-panel-1913)
-   [Rust](#tab-panel-1914)
-   [C#](#tab-panel-1915)
-   [Go](#tab-panel-1916)
-   [Node.js](#tab-panel-1917)
-   [C](#tab-panel-1918)
-   [Java](#tab-panel-1919)
-   [Python](#tab-panel-1920)

```java
String exp = "$.stock.{#0:1~5}.remove().count() > 0";
```

```python
exp = "$.stock.{#0:1~5}.remove().count() > 0"
```

```rust
use aerospike::expressions::maps as map_exp;

use aerospike::expressions::{gt, int_val, map_bin};

use aerospike::MapReturnType;

let exp = gt(

    map_exp::size(

        map_exp::remove_by_value_relative_rank_range_count(

            MapReturnType::None,

            int_val(5),

            int_val(0),

            int_val(2),

            map_bin("stock".into()),

            &[]),

        &[]),

    int_val(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)));
```

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

exp := as.ExpGreater(

  as.ExpMapSize(

    as.ExpMapRemoveByValueRelativeRankRangeCount(

      as.MapReturnType.NONE,

      as.ExpIntVal(5),

      as.ExpIntVal(0),

      as.ExpIntVal(2),

      as.ExpMapBin("stock"),

    ),

  ),

  as.ExpIntVal(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),

)
```

```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)));
```

```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()
```

---

#### `map_remove_by_rel_rank_range_to_end`

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

Description: Returns the map with every element from the rank `rank` places from `value` to the highest rank removed.

Arguments: | Name | Type | Description |
| --- | --- | --- |
| `context` | `Context instance` | 
Optional [context path](https://aerospike.com/docs/develop/data-types/collections/context) selecting a List or Map nested inside the operand. Omit it to operate on the top level.

 |
| `value` | `any` | 

Value that `rank` is measured from. It need not be present in the collection — the rank is taken from where it would sort.

 |
| `rank` | `integer` | 

Rank of the element in value order, 0 being the smallest. A negative rank counts back from the largest.

 |
| `bin` | `map` | 

Map bin to operate on, or any expression that evaluates to a map.

 |

Returns: `map`

Introduced: 5.2.0.4

Operate API operation: [`remove_by_value_rel_rank_range`](https://aerospike.com/docs/develop/data-types/collections/map/operations#remove_by_value_rel_rank_range)

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

-   [Java SDK](#tab-panel-1921)
-   [Python SDK](#tab-panel-1922)
-   [Rust](#tab-panel-1923)
-   [C#](#tab-panel-1924)
-   [Go](#tab-panel-1925)
-   [Node.js](#tab-panel-1926)
-   [C](#tab-panel-1927)
-   [Java](#tab-panel-1928)
-   [Python](#tab-panel-1929)

```java
String exp = "$.stock.{#0:~5}.remove().count() > 0";
```

```python
exp = "$.stock.{#0:~5}.remove().count() > 0"
```

```rust
use aerospike::expressions::maps as map_exp;

use aerospike::expressions::{gt, int_val, map_bin};

use aerospike::MapReturnType;

let exp = gt(

    map_exp::size(

        map_exp::remove_by_value_relative_rank_range(

            MapReturnType::None,

            int_val(5),

            int_val(0),

            map_bin("stock".into()),

            &[]),

        &[]),

    int_val(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)));
```

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

exp := as.ExpGreater(

  as.ExpMapSize(

    as.ExpMapRemoveByValueRelativeRankRange(

      as.MapReturnType.NONE,

      as.ExpIntVal(5),

      as.ExpIntVal(0),

      as.ExpMapBin("stock"),

    ),

  ),

  as.ExpIntVal(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),

)
```

```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)));
```

```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()
```

---

#### `map_remove_by_value`

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

Description: Returns the map with every element whose value equals `value` removed.

Arguments: | Name | Type | Description |
| --- | --- | --- |
| `context` | `Context instance` | 
Optional [context path](https://aerospike.com/docs/develop/data-types/collections/context) selecting a List or Map nested inside the operand. Omit it to operate on the top level.

 |
| `value` | `any` | 

Value to match. Every entry whose value equals it is removed.

 |
| `bin` | `map` | 

Map bin to operate on, or any expression that evaluates to a map.

 |

Returns: `map`

Introduced: 5.2.0.4

Operate API operation: [`remove_all_by_value`](https://aerospike.com/docs/develop/data-types/collections/map/operations#remove_all_by_value)

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

-   [Java SDK](#tab-panel-1930)
-   [Python SDK](#tab-panel-1931)
-   [Rust](#tab-panel-1932)
-   [C#](#tab-panel-1933)
-   [Go](#tab-panel-1934)
-   [Node.js](#tab-panel-1935)
-   [C](#tab-panel-1936)
-   [Java](#tab-panel-1937)
-   [Python](#tab-panel-1938)

```java
String exp = "$.stock.{=12}.remove().count() > 0";
```

```python
exp = "$.stock.{=12}.remove().count() > 0"
```

```rust
use aerospike::expressions::maps as map_exp;

use aerospike::expressions::{gt, int_val, map_bin};

use aerospike::MapReturnType;

let exp = gt(

    map_exp::size(

        map_exp::remove_by_value(

            MapReturnType::None,

            int_val(12),

            map_bin("stock".into()),

            &[]),

        &[]),

    int_val(0));
```

```csharp
Expression exp = Exp.Build(

  Exp.GT(

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

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

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

exp := as.ExpGreater(

  as.ExpMapSize(

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

  ),

  as.ExpIntVal(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),

)
```

```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)));
```

```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()
```

---

#### `map_remove_by_value_list`

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

Description: Returns the map with every element whose value is in `values` removed.

Arguments: | Name | Type | Description |
| --- | --- | --- |
| `context` | `Context instance` | 
Optional [context path](https://aerospike.com/docs/develop/data-types/collections/context) selecting a List or Map nested inside the operand. Omit it to operate on the top level.

 |
| `values` | `list` | 

Values to match, as a list. Every entry whose value equals any of them is removed.

 |
| `bin` | `map` | 

Map bin to operate on, or any expression that evaluates to a map.

 |

Returns: `map`

Introduced: 5.2.0.4

Operate API operation: [`remove_all_by_value_list`](https://aerospike.com/docs/develop/data-types/collections/map/operations#remove_all_by_value_list)

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

-   [Java SDK](#tab-panel-1939)
-   [Python SDK](#tab-panel-1940)
-   [Rust](#tab-panel-1941)
-   [C#](#tab-panel-1942)
-   [Go](#tab-panel-1943)
-   [Node.js](#tab-panel-1944)
-   [C](#tab-panel-1945)
-   [Java](#tab-panel-1946)
-   [Python](#tab-panel-1947)

```java
String exp = "$.stock.{=5, 12}.remove().count() > 0";
```

```python
exp = "$.stock.{=5, 12}.remove().count() > 0"
```

```rust
use aerospike::expressions::maps as map_exp;

use aerospike::expressions::{gt, int_val, list_val, map_bin};

use aerospike::{MapReturnType, Value};

let exp = gt(

    map_exp::size(

        map_exp::remove_by_value_list(

            MapReturnType::None,

            list_val(vec![Value::from(5), Value::from(12)]),

            map_bin("stock".into()),

            &[]),

        &[]),

    int_val(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)));
```

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

exp := as.ExpGreater(

  as.ExpMapSize(

    as.ExpMapRemoveByValueList(

      as.MapReturnType.NONE,

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

      as.ExpMapBin("stock"),

    ),

  ),

  as.ExpIntVal(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),

)
```

```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);
```

```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()
```

---

#### `map_remove_by_value_range`

```python
map_remove_by_value_range(context, value_begin, value_end, bin)
```

Description: Returns the map with every element whose value is in the interval `value_begin` ≤ v < `value_end` removed.

Arguments: | Name | Type | Description |
| --- | --- | --- |
| `context` | `Context instance` | 
Optional [context path](https://aerospike.com/docs/develop/data-types/collections/context) selecting a List or Map nested inside the operand. Omit it to operate on the top level.

 |
| `value_begin` | `any` | 

Lowest value to match, inclusive.

 |
| `value_end` | `any` | 

Upper bound on the value, exclusive. Omit it to match everything from `value_begin` upward.

 |
| `bin` | `map` | 

Map bin to operate on, or any expression that evaluates to a map.

 |

Returns: `map`

Introduced: 5.2.0.4

Operate API operation: [`remove_by_value_interval`](https://aerospike.com/docs/develop/data-types/collections/map/operations#remove_by_value_interval)

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

-   [Java SDK](#tab-panel-1948)
-   [Python SDK](#tab-panel-1949)
-   [Rust](#tab-panel-1950)
-   [C#](#tab-panel-1951)
-   [Go](#tab-panel-1952)
-   [Node.js](#tab-panel-1953)
-   [C](#tab-panel-1954)
-   [Java](#tab-panel-1955)
-   [Python](#tab-panel-1956)

```java
String exp = "$.stock.{=5:20}.remove().count() > 0";
```

```python
exp = "$.stock.{=5:20}.remove().count() > 0"
```

```rust
use aerospike::expressions::maps as map_exp;

use aerospike::expressions::{gt, int_val, map_bin};

use aerospike::MapReturnType;

let exp = gt(

    map_exp::size(

        map_exp::remove_by_value_range(

            MapReturnType::None,

            Some(int_val(5)),

            Some(int_val(20)),

            map_bin("stock".into()),

            &[]),

        &[]),

    int_val(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)));
```

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

exp := as.ExpGreater(

  as.ExpMapSize(

    as.ExpMapRemoveByValueRange(

      as.MapReturnType.NONE,

      as.ExpIntVal(5),

      as.ExpIntVal(20),

      as.ExpMapBin("stock"),

    ),

  ),

  as.ExpIntVal(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),

)
```

```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)));
```

```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()
```

---

## Read

#### `map_get_by_index`

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

Description: Returns the element at `index`.

Arguments: | Name | Type | Description |
| --- | --- | --- |
| `type` | `integer literal` | 
Data type of the element being read. Expressions are strictly typed, so this getter declares the type it evaluates to; an element of another type fails the expression.

 |
| `context` | `Context instance` | 

Optional [context path](https://aerospike.com/docs/develop/data-types/collections/context) selecting a List or Map nested inside the operand. Omit it to operate on the top level.

 |
| `result_type` | `integer literal` | 

Which form the result takes, such as count, index, rank, or value. See [Return types](https://aerospike.com/docs/develop/data-types/collections/map/operations#return-types).

 |
| `index` | `integer` | 

Zero-based position in the collection, 0 being the first element. A negative index counts back from the end.

 |
| `bin` | `map` | 

Map bin to operate on, or any expression that evaluates to a map.

 |

Returns: `any`

Introduced: 5.2.0.4

Operate API operation: [`get_by_index`](https://aerospike.com/docs/develop/data-types/collections/map/operations#get_by_index)

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

-   [Java SDK](#tab-panel-1957)
-   [Python SDK](#tab-panel-1958)
-   [Rust](#tab-panel-1959)
-   [C#](#tab-panel-1960)
-   [Go](#tab-panel-1961)
-   [Node.js](#tab-panel-1962)
-   [C](#tab-panel-1963)
-   [Java](#tab-panel-1964)
-   [Python](#tab-panel-1965)

```java
String exp = "$.stock.{0} == 12";
```

```python
exp = "$.stock.{0} == 12"
```

```rust
use aerospike::expressions::maps as map_exp;

use aerospike::expressions::{ExpType, eq, int_val, map_bin};

use aerospike::MapReturnType;

let exp = eq(

    map_exp::get_by_index(

        MapReturnType::Value,

        ExpType::INT,

        int_val(0),

        map_bin("stock".into()),

        &[]),

    int_val(12));
```

```csharp
Expression exp = Exp.Build(

  Exp.EQ(

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

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

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

exp := as.ExpEq(

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

  as.ExpIntVal(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),

)
```

```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)));
```

```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()
```

---

#### `map_get_by_index_range`

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

Description: Returns `count` elements starting at `index`.

Arguments: | Name | Type | Description |
| --- | --- | --- |
| `context` | `Context instance` | 
Optional [context path](https://aerospike.com/docs/develop/data-types/collections/context) selecting a List or Map nested inside the operand. Omit it to operate on the top level.

 |
| `result_type` | `integer literal` | 

Which form the result takes, such as count, index, rank, or value. See [Return types](https://aerospike.com/docs/develop/data-types/collections/map/operations#return-types).

 |
| `index` | `integer` | 

Zero-based position in the collection, 0 being the first element. A negative index counts back from the end.

 |
| `count` | `integer` | 

Number of elements in the range.

 |
| `bin` | `map` | 

Map bin to operate on, or any expression that evaluates to a map.

 |

Returns: `any`

Introduced: 5.2.0.4

Operate API operation: [`get_by_index_range`](https://aerospike.com/docs/develop/data-types/collections/map/operations#get_by_index_range)

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

-   [Java SDK](#tab-panel-1966)
-   [Python SDK](#tab-panel-1967)
-   [Rust](#tab-panel-1968)
-   [C#](#tab-panel-1969)
-   [Go](#tab-panel-1970)
-   [Node.js](#tab-panel-1971)
-   [C](#tab-panel-1972)
-   [Java](#tab-panel-1973)
-   [Python](#tab-panel-1974)

```java
String exp = "$.stock.{0:2}.count() == 2";
```

```python
exp = "$.stock.{0:2}.count() == 2"
```

```rust
use aerospike::expressions::maps as map_exp;

use aerospike::expressions::{eq, int_val, map_bin};

use aerospike::MapReturnType;

let exp = eq(

    map_exp::get_by_index_range_count(

        MapReturnType::Count,

        int_val(0),

        int_val(2),

        map_bin("stock".into()),

        &[]),

    int_val(2));
```

```csharp
Expression exp = Exp.Build(

  Exp.EQ(

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

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

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

exp := as.ExpEq(

  as.ExpMapGetByIndexRangeCount(

    as.MapReturnType.COUNT,

    as.ExpIntVal(0),

    as.ExpIntVal(2),

    as.ExpMapBin("stock"),

  ),

  as.ExpIntVal(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),

)
```

```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)));
```

```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()
```

---

#### `map_get_by_index_range_to_end`

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

Description: Returns every element from `index` to the end.

Arguments: | Name | Type | Description |
| --- | --- | --- |
| `context` | `Context instance` | 
Optional [context path](https://aerospike.com/docs/develop/data-types/collections/context) selecting a List or Map nested inside the operand. Omit it to operate on the top level.

 |
| `result_type` | `integer literal` | 

Which form the result takes, such as count, index, rank, or value. See [Return types](https://aerospike.com/docs/develop/data-types/collections/map/operations#return-types).

 |
| `index` | `integer` | 

Zero-based position in the collection, 0 being the first element. A negative index counts back from the end.

 |
| `bin` | `map` | 

Map bin to operate on, or any expression that evaluates to a map.

 |

Returns: `any`

Introduced: 5.2.0.4

Operate API operation: [`get_by_index_range`](https://aerospike.com/docs/develop/data-types/collections/map/operations#get_by_index_range)

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

-   [Java SDK](#tab-panel-1975)
-   [Python SDK](#tab-panel-1976)
-   [Rust](#tab-panel-1977)
-   [C#](#tab-panel-1978)
-   [Go](#tab-panel-1979)
-   [Node.js](#tab-panel-1980)
-   [C](#tab-panel-1981)
-   [Java](#tab-panel-1982)
-   [Python](#tab-panel-1983)

```java
String exp = "$.stock.{1:}.count() > 0";
```

```python
exp = "$.stock.{1:}.count() > 0"
```

```rust
use aerospike::expressions::maps as map_exp;

use aerospike::expressions::{gt, int_val, map_bin};

use aerospike::MapReturnType;

let exp = gt(

    map_exp::get_by_index_range(

        MapReturnType::Count,

        int_val(1),

        map_bin("stock".into()),

        &[]),

    int_val(0));
```

```csharp
Expression exp = Exp.Build(

  Exp.GT(

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

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

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

exp := as.ExpGreater(

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

  as.ExpIntVal(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),

)
```

```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)));
```

```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()
```

---

#### `map_get_by_key`

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

Description: Returns the element at `key`.

Arguments: | Name | Type | Description |
| --- | --- | --- |
| `type` | `integer literal` | 
Data type of the element being read. Expressions are strictly typed, so this getter declares the type it evaluates to; an element of another type fails the expression.

 |
| `context` | `Context instance` | 

Optional [context path](https://aerospike.com/docs/develop/data-types/collections/context) selecting a List or Map nested inside the operand. Omit it to operate on the top level.

 |
| `result_type` | `integer literal` | 

Which form the result takes, such as count, index, rank, or value. See [Return types](https://aerospike.com/docs/develop/data-types/collections/map/operations#return-types).

 |
| `key` | `any` | 

Map key the operation applies to.

 |
| `bin` | `map` | 

Map bin to operate on, or any expression that evaluates to a map.

 |

Returns: `any`

Introduced: 5.2.0.4

Operate API operation: [`get_by_key`](https://aerospike.com/docs/develop/data-types/collections/map/operations#get_by_key)

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

-   [Java SDK](#tab-panel-1984)
-   [Python SDK](#tab-panel-1985)
-   [Rust](#tab-panel-1986)
-   [C#](#tab-panel-1987)
-   [Go](#tab-panel-1988)
-   [Node.js](#tab-panel-1989)
-   [C](#tab-panel-1990)
-   [Java](#tab-panel-1991)
-   [Python](#tab-panel-1992)

```java
String exp = "$.stock.'sku-a' == 12";
```

```python
exp = "$.stock.'sku-a' == 12"
```

```rust
use aerospike::expressions::maps as map_exp;

use aerospike::expressions::{ExpType, eq, int_val, map_bin, string_val};

use aerospike::MapReturnType;

let exp = eq(

    map_exp::get_by_key(

        MapReturnType::Value,

        ExpType::INT,

        string_val("sku-a".into()),

        map_bin("stock".into()),

        &[]),

    int_val(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)));
```

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

exp := as.ExpEq(

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

  as.ExpIntVal(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),

)
```

```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)));
```

```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()
```

---

#### `map_get_by_key_list`

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

Description: Returns every element whose key is in `keys`.

Arguments: | Name | Type | Description |
| --- | --- | --- |
| `context` | `Context instance` | 
Optional [context path](https://aerospike.com/docs/develop/data-types/collections/context) selecting a List or Map nested inside the operand. Omit it to operate on the top level.

 |
| `result_type` | `integer literal` | 

Which form the result takes, such as count, index, rank, or value. See [Return types](https://aerospike.com/docs/develop/data-types/collections/map/operations#return-types).

 |
| `keys` | `list` | 

Keys to match, as a list. Every entry whose key appears in it is selected.

 |
| `bin` | `map` | 

Map bin to operate on, or any expression that evaluates to a map.

 |

Returns: `any`

Introduced: 5.2.0.4

Operate API operation: [`get_all_by_key_list`](https://aerospike.com/docs/develop/data-types/collections/map/operations#get_all_by_key_list)

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

-   [Java SDK](#tab-panel-1993)
-   [Python SDK](#tab-panel-1994)
-   [Rust](#tab-panel-1995)
-   [C#](#tab-panel-1996)
-   [Go](#tab-panel-1997)
-   [Node.js](#tab-panel-1998)
-   [C](#tab-panel-1999)
-   [Java](#tab-panel-2000)
-   [Python](#tab-panel-2001)

```java
String exp = "$.stock.{@'sku-a', 'sku-b'}.count() > 0";
```

```python
exp = "$.stock.{@'sku-a', 'sku-b'}.count() > 0"
```

```rust
use aerospike::expressions::maps as map_exp;

use aerospike::expressions::{gt, int_val, list_val, map_bin};

use aerospike::{MapReturnType, Value};

let exp = gt(

    map_exp::get_by_key_list(

        MapReturnType::Count,

        list_val(vec![Value::from("sku-a"), Value::from("sku-b")]),

        map_bin("stock".into()),

        &[]),

    int_val(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)));
```

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

exp := as.ExpGreater(

  as.ExpMapGetByKeyList(

    as.MapReturnType.COUNT,

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

    as.ExpMapBin("stock"),

  ),

  as.ExpIntVal(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),

)
```

```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);
```

```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()
```

---

#### `map_get_by_key_range`

```python
map_get_by_key_range(context, result_type, key_begin, key_end, bin)
```

Description: Returns every element whose key is in the interval `key_begin` ≤ k < `key_end`.

Arguments: | Name | Type | Description |
| --- | --- | --- |
| `context` | `Context instance` | 
Optional [context path](https://aerospike.com/docs/develop/data-types/collections/context) selecting a List or Map nested inside the operand. Omit it to operate on the top level.

 |
| `result_type` | `integer literal` | 

Which form the result takes, such as count, index, rank, or value. See [Return types](https://aerospike.com/docs/develop/data-types/collections/map/operations#return-types).

 |
| `key_begin` | `any` | 

Lowest key to match, inclusive.

 |
| `key_end` | `any` | 

Upper bound on the key, exclusive. Omit it to match everything from `key_begin` upward.

 |
| `bin` | `map` | 

Map bin to operate on, or any expression that evaluates to a map.

 |

Returns: `any`

Introduced: 5.2.0.4

Operate API operation: [`get_by_key_interval`](https://aerospike.com/docs/develop/data-types/collections/map/operations#get_by_key_interval)

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

-   [Java SDK](#tab-panel-2002)
-   [Python SDK](#tab-panel-2003)
-   [Rust](#tab-panel-2004)
-   [C#](#tab-panel-2005)
-   [Go](#tab-panel-2006)
-   [Node.js](#tab-panel-2007)
-   [C](#tab-panel-2008)
-   [Java](#tab-panel-2009)
-   [Python](#tab-panel-2010)

```java
String exp = "$.stock.{@:'sku-z'}.count() > 0";
```

```python
exp = "$.stock.{@:'sku-z'}.count() > 0"
```

```rust
use aerospike::expressions::maps as map_exp;

use aerospike::expressions::{gt, int_val, map_bin, string_val};

use aerospike::MapReturnType;

let exp = gt(

    map_exp::get_by_key_range(

        MapReturnType::Count,

        None,

        Some(string_val("sku-z".into())),

        map_bin("stock".into()),

        &[]),

    int_val(0));
```

```csharp
Expression exp = Exp.Build(

  Exp.GT(

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

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

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

exp := as.ExpGreater(

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

  as.ExpIntVal(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),

)
```

```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)));
```

```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()
```

---

#### `map_get_by_rank`

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

Description: Returns the element of rank `rank`.

Arguments: | Name | Type | Description |
| --- | --- | --- |
| `type` | `integer literal` | 
Data type of the element being read. Expressions are strictly typed, so this getter declares the type it evaluates to; an element of another type fails the expression.

 |
| `context` | `Context instance` | 

Optional [context path](https://aerospike.com/docs/develop/data-types/collections/context) selecting a List or Map nested inside the operand. Omit it to operate on the top level.

 |
| `result_type` | `integer literal` | 

Which form the result takes, such as count, index, rank, or value. See [Return types](https://aerospike.com/docs/develop/data-types/collections/map/operations#return-types).

 |
| `rank` | `integer` | 

Rank of the element in value order, 0 being the smallest. A negative rank counts back from the largest.

 |
| `bin` | `map` | 

Map bin to operate on, or any expression that evaluates to a map.

 |

Returns: `any`

Introduced: 5.2.0.4

Operate API operation: [`get_by_rank`](https://aerospike.com/docs/develop/data-types/collections/map/operations#get_by_rank)

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

-   [Java SDK](#tab-panel-2011)
-   [Python SDK](#tab-panel-2012)
-   [Rust](#tab-panel-2013)
-   [C#](#tab-panel-2014)
-   [Go](#tab-panel-2015)
-   [Node.js](#tab-panel-2016)
-   [C](#tab-panel-2017)
-   [Java](#tab-panel-2018)
-   [Python](#tab-panel-2019)

```java
String exp = "$.stock.{#0} == 5";
```

```python
exp = "$.stock.{#0} == 5"
```

```rust
use aerospike::expressions::maps as map_exp;

use aerospike::expressions::{ExpType, eq, int_val, map_bin};

use aerospike::MapReturnType;

let exp = eq(

    map_exp::get_by_rank(

        MapReturnType::Value,

        ExpType::INT,

        int_val(0),

        map_bin("stock".into()),

        &[]),

    int_val(5));
```

```csharp
Expression exp = Exp.Build(

  Exp.EQ(

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

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

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

exp := as.ExpEq(

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

  as.ExpIntVal(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),

)
```

```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)));
```

```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()
```

---

#### `map_get_by_rank_range`

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

Description: Returns `count` elements starting at rank `rank`.

Arguments: | Name | Type | Description |
| --- | --- | --- |
| `context` | `Context instance` | 
Optional [context path](https://aerospike.com/docs/develop/data-types/collections/context) selecting a List or Map nested inside the operand. Omit it to operate on the top level.

 |
| `result_type` | `integer literal` | 

Which form the result takes, such as count, index, rank, or value. See [Return types](https://aerospike.com/docs/develop/data-types/collections/map/operations#return-types).

 |
| `rank` | `integer` | 

Rank of the element in value order, 0 being the smallest. A negative rank counts back from the largest.

 |
| `count` | `integer` | 

Number of elements in the range.

 |
| `bin` | `map` | 

Map bin to operate on, or any expression that evaluates to a map.

 |

Returns: `any`

Introduced: 5.2.0.4

Operate API operation: [`get_by_rank_range`](https://aerospike.com/docs/develop/data-types/collections/map/operations#get_by_rank_range)

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

-   [Java SDK](#tab-panel-2020)
-   [Python SDK](#tab-panel-2021)
-   [Rust](#tab-panel-2022)
-   [C#](#tab-panel-2023)
-   [Go](#tab-panel-2024)
-   [Node.js](#tab-panel-2025)
-   [C](#tab-panel-2026)
-   [Java](#tab-panel-2027)
-   [Python](#tab-panel-2028)

```java
String exp = "$.stock.{#0:2}.count() == 2";
```

```python
exp = "$.stock.{#0:2}.count() == 2"
```

```rust
use aerospike::expressions::maps as map_exp;

use aerospike::expressions::{eq, int_val, map_bin};

use aerospike::MapReturnType;

let exp = eq(

    map_exp::get_by_rank_range_count(

        MapReturnType::Count,

        int_val(0),

        int_val(2),

        map_bin("stock".into()),

        &[]),

    int_val(2));
```

```csharp
Expression exp = Exp.Build(

  Exp.EQ(

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

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

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

exp := as.ExpEq(

  as.ExpMapGetByRankRangeCount(

    as.MapReturnType.COUNT,

    as.ExpIntVal(0),

    as.ExpIntVal(2),

    as.ExpMapBin("stock"),

  ),

  as.ExpIntVal(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),

)
```

```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)));
```

```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()
```

---

#### `map_get_by_rank_range_to_end`

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

Description: Returns every element of rank `rank` or higher.

Arguments: | Name | Type | Description |
| --- | --- | --- |
| `context` | `Context instance` | 
Optional [context path](https://aerospike.com/docs/develop/data-types/collections/context) selecting a List or Map nested inside the operand. Omit it to operate on the top level.

 |
| `result_type` | `integer literal` | 

Which form the result takes, such as count, index, rank, or value. See [Return types](https://aerospike.com/docs/develop/data-types/collections/map/operations#return-types).

 |
| `rank` | `integer` | 

Rank of the element in value order, 0 being the smallest. A negative rank counts back from the largest.

 |
| `bin` | `map` | 

Map bin to operate on, or any expression that evaluates to a map.

 |

Returns: `any`

Introduced: 5.2.0.4

Operate API operation: [`get_by_rank_range`](https://aerospike.com/docs/develop/data-types/collections/map/operations#get_by_rank_range)

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

-   [Java SDK](#tab-panel-2029)
-   [Python SDK](#tab-panel-2030)
-   [Rust](#tab-panel-2031)
-   [C#](#tab-panel-2032)
-   [Go](#tab-panel-2033)
-   [Node.js](#tab-panel-2034)
-   [C](#tab-panel-2035)
-   [Java](#tab-panel-2036)
-   [Python](#tab-panel-2037)

```java
String exp = "$.stock.{#0:}.count() > 0";
```

```python
exp = "$.stock.{#0:}.count() > 0"
```

```rust
use aerospike::expressions::maps as map_exp;

use aerospike::expressions::{gt, int_val, map_bin};

use aerospike::MapReturnType;

let exp = gt(

    map_exp::get_by_rank_range(

        MapReturnType::Count,

        int_val(0),

        map_bin("stock".into()),

        &[]),

    int_val(0));
```

```csharp
Expression exp = Exp.Build(

  Exp.GT(

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

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

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

exp := as.ExpGreater(

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

  as.ExpIntVal(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),

)
```

```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)));
```

```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()
```

---

#### `map_get_by_rel_index_range`

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

Description: Returns `count` elements starting at the index `index` places from `key`.

Arguments: | Name | Type | Description |
| --- | --- | --- |
| `context` | `Context instance` | 
Optional [context path](https://aerospike.com/docs/develop/data-types/collections/context) selecting a List or Map nested inside the operand. Omit it to operate on the top level.

 |
| `result_type` | `integer literal` | 

Which form the result takes, such as count, index, rank, or value. See [Return types](https://aerospike.com/docs/develop/data-types/collections/map/operations#return-types).

 |
| `key` | `any` | 

Map key the operation applies to.

 |
| `index` | `integer` | 

Zero-based position in the collection, 0 being the first element. A negative index counts back from the end.

 |
| `count` | `integer` | 

Number of elements in the range.

 |
| `bin` | `map` | 

Map bin to operate on, or any expression that evaluates to a map.

 |

Returns: `any`

Introduced: 5.2.0.4

Operate API operation: [`get_by_key_rel_index_range`](https://aerospike.com/docs/develop/data-types/collections/map/operations#get_by_key_rel_index_range)

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

-   [Java SDK](#tab-panel-2038)
-   [Python SDK](#tab-panel-2039)
-   [Rust](#tab-panel-2040)
-   [C#](#tab-panel-2041)
-   [Go](#tab-panel-2042)
-   [Node.js](#tab-panel-2043)
-   [C](#tab-panel-2044)
-   [Java](#tab-panel-2045)
-   [Python](#tab-panel-2046)

```java
String exp = "$.stock.{0:0~'sku-a'}.count() == 1";
```

```python
exp = "$.stock.{0:0~'sku-a'}.count() == 1"
```

```rust
use aerospike::expressions::maps as map_exp;

use aerospike::expressions::{eq, int_val, map_bin, string_val};

use aerospike::MapReturnType;

let exp = eq(

    map_exp::get_by_key_relative_index_range_count(

        MapReturnType::Count,

        string_val("sku-a".into()),

        int_val(0),

        int_val(1),

        map_bin("stock".into()),

        &[]),

    int_val(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)));
```

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

exp := as.ExpEq(

  as.ExpMapGetByKeyRelativeIndexRangeCount(

    as.MapReturnType.COUNT,

    as.ExpStringVal("sku-a"),

    as.ExpIntVal(0),

    as.ExpIntVal(1),

    as.ExpMapBin("stock"),

  ),

  as.ExpIntVal(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),

)
```

```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)));
```

```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()
```

---

#### `map_get_by_rel_index_range_to_end`

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

Description: Returns every element from the index `index` places from `key` to the end.

Arguments: | Name | Type | Description |
| --- | --- | --- |
| `context` | `Context instance` | 
Optional [context path](https://aerospike.com/docs/develop/data-types/collections/context) selecting a List or Map nested inside the operand. Omit it to operate on the top level.

 |
| `result_type` | `integer literal` | 

Which form the result takes, such as count, index, rank, or value. See [Return types](https://aerospike.com/docs/develop/data-types/collections/map/operations#return-types).

 |
| `key` | `any` | 

Map key the operation applies to.

 |
| `index` | `integer` | 

Zero-based position in the collection, 0 being the first element. A negative index counts back from the end.

 |
| `bin` | `map` | 

Map bin to operate on, or any expression that evaluates to a map.

 |

Returns: `any`

Introduced: 5.2.0.4

Operate API operation: [`get_by_key_rel_index_range`](https://aerospike.com/docs/develop/data-types/collections/map/operations#get_by_key_rel_index_range)

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

-   [Java SDK](#tab-panel-2047)
-   [Python SDK](#tab-panel-2048)
-   [Rust](#tab-panel-2049)
-   [C#](#tab-panel-2050)
-   [Go](#tab-panel-2051)
-   [Node.js](#tab-panel-2052)
-   [C](#tab-panel-2053)
-   [Java](#tab-panel-2054)
-   [Python](#tab-panel-2055)

```java
String exp = "$.stock.{0:~'sku-a'}.count() > 0";
```

```python
exp = "$.stock.{0:~'sku-a'}.count() > 0"
```

```rust
use aerospike::expressions::maps as map_exp;

use aerospike::expressions::{gt, int_val, map_bin, string_val};

use aerospike::MapReturnType;

let exp = gt(

    map_exp::get_by_key_relative_index_range(

        MapReturnType::Count,

        string_val("sku-a".into()),

        int_val(0),

        map_bin("stock".into()),

        &[]),

    int_val(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)));
```

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

exp := as.ExpGreater(

  as.ExpMapGetByKeyRelativeIndexRange(

    as.MapReturnType.COUNT,

    as.ExpStringVal("sku-a"),

    as.ExpIntVal(0),

    as.ExpMapBin("stock"),

  ),

  as.ExpIntVal(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),

)
```

```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)));
```

```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()
```

---

#### `map_get_by_rel_rank_range`

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

Description: Returns `count` elements starting at the rank `rank` places from `value`.

Arguments: | Name | Type | Description |
| --- | --- | --- |
| `context` | `Context instance` | 
Optional [context path](https://aerospike.com/docs/develop/data-types/collections/context) selecting a List or Map nested inside the operand. Omit it to operate on the top level.

 |
| `result_type` | `integer literal` | 

Which form the result takes, such as count, index, rank, or value. See [Return types](https://aerospike.com/docs/develop/data-types/collections/map/operations#return-types).

 |
| `value` | `any` | 

Value that `rank` is measured from. It need not be present in the collection — the rank is taken from where it would sort.

 |
| `rank` | `integer` | 

Rank of the element in value order, 0 being the smallest. A negative rank counts back from the largest.

 |
| `count` | `integer` | 

Number of elements in the range.

 |
| `bin` | `map` | 

Map bin to operate on, or any expression that evaluates to a map.

 |

Returns: `any`

Introduced: 5.2.0.4

Operate API operation: [`get_by_value_rel_rank_range`](https://aerospike.com/docs/develop/data-types/collections/map/operations#get_by_value_rel_rank_range)

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

-   [Java SDK](#tab-panel-2056)
-   [Python SDK](#tab-panel-2057)
-   [Rust](#tab-panel-2058)
-   [C#](#tab-panel-2059)
-   [Go](#tab-panel-2060)
-   [Node.js](#tab-panel-2061)
-   [C](#tab-panel-2062)
-   [Java](#tab-panel-2063)
-   [Python](#tab-panel-2064)

```java
String exp = "$.stock.{#0:1~5}.count() > 0";
```

```python
exp = "$.stock.{#0:1~5}.count() > 0"
```

```rust
use aerospike::expressions::maps as map_exp;

use aerospike::expressions::{gt, int_val, map_bin};

use aerospike::MapReturnType;

let exp = gt(

    map_exp::get_by_value_relative_rank_range_count(

        MapReturnType::Count,

        int_val(5),

        int_val(0),

        int_val(2),

        map_bin("stock".into()),

        &[]),

    int_val(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)));
```

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

exp := as.ExpGreater(

  as.ExpMapGetByValueRelativeRankRangeCount(

    as.MapReturnType.COUNT,

    as.ExpIntVal(5),

    as.ExpIntVal(0),

    as.ExpIntVal(2),

    as.ExpMapBin("stock"),

  ),

  as.ExpIntVal(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),

)
```

```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)));
```

```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()
```

---

#### `map_get_by_rel_rank_range_to_end`

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

Description: Returns every element from the rank `rank` places from `value` to the highest rank.

Arguments: | Name | Type | Description |
| --- | --- | --- |
| `context` | `Context instance` | 
Optional [context path](https://aerospike.com/docs/develop/data-types/collections/context) selecting a List or Map nested inside the operand. Omit it to operate on the top level.

 |
| `result_type` | `integer literal` | 

Which form the result takes, such as count, index, rank, or value. See [Return types](https://aerospike.com/docs/develop/data-types/collections/map/operations#return-types).

 |
| `value` | `any` | 

Value that `rank` is measured from. It need not be present in the collection — the rank is taken from where it would sort.

 |
| `rank` | `integer` | 

Rank of the element in value order, 0 being the smallest. A negative rank counts back from the largest.

 |
| `bin` | `map` | 

Map bin to operate on, or any expression that evaluates to a map.

 |

Returns: `any`

Introduced: 5.2.0.4

Operate API operation: [`get_by_value_rel_rank_range`](https://aerospike.com/docs/develop/data-types/collections/map/operations#get_by_value_rel_rank_range)

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

-   [Java SDK](#tab-panel-2065)
-   [Python SDK](#tab-panel-2066)
-   [Rust](#tab-panel-2067)
-   [C#](#tab-panel-2068)
-   [Go](#tab-panel-2069)
-   [Node.js](#tab-panel-2070)
-   [C](#tab-panel-2071)
-   [Java](#tab-panel-2072)
-   [Python](#tab-panel-2073)

```java
String exp = "$.stock.{#0:~5}.count() > 0";
```

```python
exp = "$.stock.{#0:~5}.count() > 0"
```

```rust
use aerospike::expressions::maps as map_exp;

use aerospike::expressions::{gt, int_val, map_bin};

use aerospike::MapReturnType;

let exp = gt(

    map_exp::get_by_value_relative_rank_range(

        MapReturnType::Count,

        int_val(5),

        int_val(0),

        map_bin("stock".into()),

        &[]),

    int_val(0));
```

```csharp
Expression exp = Exp.Build(

  Exp.GT(

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

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

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

exp := as.ExpGreater(

  as.ExpMapGetByValueRelativeRankRange(

    as.MapReturnType.COUNT,

    as.ExpIntVal(5),

    as.ExpIntVal(0),

    as.ExpMapBin("stock"),

  ),

  as.ExpIntVal(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),

)
```

```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)));
```

```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()
```

---

#### `map_get_by_value`

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

Description: Returns every element whose value equals `value`.

Arguments: | Name | Type | Description |
| --- | --- | --- |
| `context` | `Context instance` | 
Optional [context path](https://aerospike.com/docs/develop/data-types/collections/context) selecting a List or Map nested inside the operand. Omit it to operate on the top level.

 |
| `result_type` | `integer literal` | 

Which form the result takes, such as count, index, rank, or value. See [Return types](https://aerospike.com/docs/develop/data-types/collections/map/operations#return-types).

 |
| `value` | `any` | 

Value to match. Every entry whose value equals it is selected.

 |
| `bin` | `map` | 

Map bin to operate on, or any expression that evaluates to a map.

 |

Returns: `any`

Introduced: 5.2.0.4

Operate API operation: [`get_all_by_value`](https://aerospike.com/docs/develop/data-types/collections/map/operations#get_all_by_value)

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

-   [Java SDK](#tab-panel-2074)
-   [Python SDK](#tab-panel-2075)
-   [Rust](#tab-panel-2076)
-   [C#](#tab-panel-2077)
-   [Go](#tab-panel-2078)
-   [Node.js](#tab-panel-2079)
-   [C](#tab-panel-2080)
-   [Java](#tab-panel-2081)
-   [Python](#tab-panel-2082)

```java
String exp = "$.stock.{=12,}.count() > 0";
```

```python
exp = "$.stock.{=12,}.count() > 0"
```

```rust
use aerospike::expressions::maps as map_exp;

use aerospike::expressions::{gt, int_val, map_bin};

use aerospike::MapReturnType;

let exp = gt(

    map_exp::get_by_value(

        MapReturnType::Count,

        int_val(12),

        map_bin("stock".into()),

        &[]),

    int_val(0));
```

```csharp
Expression exp = Exp.Build(

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

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

exp := as.ExpGreater(

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

  as.ExpIntVal(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),

)
```

```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)));
```

```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()
```

---

#### `map_get_by_value_list`

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

Description: Returns every element whose value is in `values`.

Arguments: | Name | Type | Description |
| --- | --- | --- |
| `context` | `Context instance` | 
Optional [context path](https://aerospike.com/docs/develop/data-types/collections/context) selecting a List or Map nested inside the operand. Omit it to operate on the top level.

 |
| `result_type` | `integer literal` | 

Which form the result takes, such as count, index, rank, or value. See [Return types](https://aerospike.com/docs/develop/data-types/collections/map/operations#return-types).

 |
| `values` | `list` | 

Values to match, as a list. Every entry whose value equals any of them is selected.

 |
| `bin` | `map` | 

Map bin to operate on, or any expression that evaluates to a map.

 |

Returns: `any`

Introduced: 5.2.0.4

Operate API operation: [`get_all_by_value_list`](https://aerospike.com/docs/develop/data-types/collections/map/operations#get_all_by_value_list)

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

-   [Java SDK](#tab-panel-2083)
-   [Python SDK](#tab-panel-2084)
-   [Rust](#tab-panel-2085)
-   [C#](#tab-panel-2086)
-   [Go](#tab-panel-2087)
-   [Node.js](#tab-panel-2088)
-   [C](#tab-panel-2089)
-   [Java](#tab-panel-2090)
-   [Python](#tab-panel-2091)

```java
String exp = "$.stock.{=5, 12}.count() > 0";
```

```python
exp = "$.stock.{=5, 12}.count() > 0"
```

```rust
use aerospike::expressions::maps as map_exp;

use aerospike::expressions::{gt, int_val, list_val, map_bin};

use aerospike::{MapReturnType, Value};

let exp = gt(

    map_exp::get_by_value_list(

        MapReturnType::Count,

        list_val(vec![Value::from(5), Value::from(12)]),

        map_bin("stock".into()),

        &[]),

    int_val(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)));
```

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

exp := as.ExpGreater(

  as.ExpMapGetByValueList(

    as.MapReturnType.COUNT,

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

    as.ExpMapBin("stock"),

  ),

  as.ExpIntVal(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),

)
```

```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);
```

```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()
```

---

#### `map_get_by_value_range`

```python
map_get_by_value_range(context, result_type, value_begin, value_end, bin)
```

Description: Returns every element whose value is in the interval `value_begin` ≤ v < `value_end`.

Arguments: | Name | Type | Description |
| --- | --- | --- |
| `context` | `Context instance` | 
Optional [context path](https://aerospike.com/docs/develop/data-types/collections/context) selecting a List or Map nested inside the operand. Omit it to operate on the top level.

 |
| `result_type` | `integer literal` | 

Which form the result takes, such as count, index, rank, or value. See [Return types](https://aerospike.com/docs/develop/data-types/collections/map/operations#return-types).

 |
| `value_begin` | `integer` | 

Lowest value to match, inclusive.

 |
| `value_end` | `integer` | 

Upper bound on the value, exclusive. Omit it to match everything from `value_begin` upward.

 |
| `bin` | `map` | 

Map bin to operate on, or any expression that evaluates to a map.

 |

Returns: `any`

Introduced: 5.2.0.4

Operate API operation: [`get_by_value_interval`](https://aerospike.com/docs/develop/data-types/collections/map/operations#get_by_value_interval)

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

-   [Java SDK](#tab-panel-2092)
-   [Python SDK](#tab-panel-2093)
-   [Rust](#tab-panel-2094)
-   [C#](#tab-panel-2095)
-   [Go](#tab-panel-2096)
-   [Node.js](#tab-panel-2097)
-   [C](#tab-panel-2098)
-   [Java](#tab-panel-2099)
-   [Python](#tab-panel-2100)

```java
String exp = "$.stock.{=5:50}.count() > 0";
```

```python
exp = "$.stock.{=5:50}.count() > 0"
```

```rust
use aerospike::expressions::maps as map_exp;

use aerospike::expressions::{gt, int_val, map_bin};

use aerospike::MapReturnType;

let exp = gt(

    map_exp::get_by_value_range(

        MapReturnType::Count,

        Some(int_val(5)),

        Some(int_val(50)),

        map_bin("stock".into()),

        &[]),

    int_val(0));
```

```csharp
Expression exp = Exp.Build(

  Exp.GT(

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

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

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

exp := as.ExpGreater(

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

  as.ExpIntVal(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),

)
```

```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)));
```

```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()
```

---

#### `map_keys`

```python
map_keys(bin)
```

Description: Returns the map’s keys as a list. Unlike the other map reads it takes neither a `context` nor a `result_type`, because there is only one thing it can return.

Arguments: | Name | Type | Description |
| --- | --- | --- |
| `bin` | `map` | 
Map bin to operate on, or any expression that evaluates to a map.

 |

Returns: `list`

Introduced: 8.1.2

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

-   [Java SDK](#tab-panel-2101)
-   [Python SDK](#tab-panel-2102)
-   [Rust](#tab-panel-2103)
-   [C#](#tab-panel-2104)
-   [Go](#tab-panel-2105)
-   [Node.js](#tab-panel-2106)
-   [C](#tab-panel-2107)
-   [Java](#tab-panel-2108)
-   [Python](#tab-panel-2109)

```java
String exp = "$.stock:MAP.*.getKeys().count() > 0";
```

```python
exp = "$.stock:MAP.*.getKeys().count() > 0"
```

```rust
use aerospike::expressions::lists as list_exp;

use aerospike::expressions::{gt, int_val, map_bin, map_keys};

let exp = gt(list_exp::size(map_keys(map_bin("stock".into())), &[]), int_val(0));
```

```csharp
Expression exp = Exp.Build(

  Exp.GT(

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

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

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

exp := as.ExpGreater(

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

  as.ExpIntVal(0),

)
```

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

const exp = Aerospike.exp

const filterExp = exp.gt(

  exp.lists.size(exp.mapKeys(exp.binMap('stock'))),

  exp.int(0),

)
```

```c
as_exp_build(predexp,

  as_exp_cmp_gt(

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

    as_exp_int(0)));
```

```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()
```

---

#### `map_size`

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

Description: Returns the number of elements in the map.

Arguments: | Name | Type | Description |
| --- | --- | --- |
| `context` | `Context instance` | 
Optional [context path](https://aerospike.com/docs/develop/data-types/collections/context) selecting a List or Map nested inside the operand. Omit it to operate on the top level.

 |
| `bin` | `map` | 

Map bin to operate on, or any expression that evaluates to a map.

 |

Returns: `integer`

Introduced: 5.2.0.4

Operate API operation: [`size`](https://aerospike.com/docs/develop/data-types/collections/map/operations#size)

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

-   [Java SDK](#tab-panel-2110)
-   [Python SDK](#tab-panel-2111)
-   [Rust](#tab-panel-2112)
-   [C#](#tab-panel-2113)
-   [Go](#tab-panel-2114)
-   [Node.js](#tab-panel-2115)
-   [C](#tab-panel-2116)
-   [Java](#tab-panel-2117)
-   [Python](#tab-panel-2118)

```java
String exp = "$.stock:MAP.count() > 0";
```

```python
exp = "$.stock:MAP.count() > 0"
```

```rust
use aerospike::expressions::maps as map_exp;

use aerospike::expressions::{gt, int_val, map_bin};

let exp = gt(map_exp::size(map_bin("stock".into()), &[]), int_val(0));
```

```csharp
Expression exp = Exp.Build(

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

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

exp := as.ExpGreater(

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

  as.ExpIntVal(0),

)
```

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

const exp = Aerospike.exp

const filterExp = exp.gt(

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

  exp.int(0),

)
```

```c
as_exp_build(predexp,

  as_exp_cmp_gt(

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

    as_exp_int(0)));
```

```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()
```

---

#### `map_values`

```python
map_values(bin)
```

Description: Returns the map’s values as a list. Unlike the other map reads it takes neither a `context` nor a `result_type`, because there is only one thing it can return.

Arguments: | Name | Type | Description |
| --- | --- | --- |
| `bin` | `map` | 
Map bin to operate on, or any expression that evaluates to a map.

 |

Returns: `list`

Introduced: 8.1.2

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

-   [Java SDK](#tab-panel-2119)
-   [Python SDK](#tab-panel-2120)
-   [Rust](#tab-panel-2121)
-   [C#](#tab-panel-2122)
-   [Go](#tab-panel-2123)
-   [Node.js](#tab-panel-2124)
-   [C](#tab-panel-2125)
-   [Java](#tab-panel-2126)
-   [Python](#tab-panel-2127)

```java
String exp = "$.stock:MAP.*.count() > 0";
```

```python
exp = "$.stock:MAP.*.count() > 0"
```

```rust
use aerospike::expressions::lists as list_exp;

use aerospike::expressions::{gt, int_val, map_bin, map_values};

let exp = gt(list_exp::size(map_values(map_bin("stock".into())), &[]), int_val(0));
```

```csharp
Expression exp = Exp.Build(

  Exp.GT(

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

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

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

exp := as.ExpGreater(

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

  as.ExpIntVal(0),

)
```

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

const exp = Aerospike.exp

const filterExp = exp.gt(

  exp.lists.size(exp.mapValues(exp.binMap('stock'))),

  exp.int(0),

)
```

```c
as_exp_build(predexp,

  as_exp_cmp_gt(

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

    as_exp_int(0)));
```

```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()
```

---