---
title: "List expressions"
description: "Guide to Aerospike list expressions for reading and modifying list values in filters, projection, and write pipelines."
---

# List expressions

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

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

Read expressions (`list_size`, `list_get_by_index`, `list_get_by_value`, the rank and range variants) evaluate to whatever `result_type` selects — a count, an index, a rank, 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 (`list_append`, `list_insert`, `list_remove_by_*`, `list_set`, `list_increment`, `list_sort`, `list_clear`) evaluate to a new list 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 list operand is a bin, read with [`bin_list`](https://aerospike.com/docs/develop/expressions/storage#bin_list), or any expression that evaluates to a list. 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 list operations as path functions, for example `$.tags.append('new')`.

## 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 list operation takes its `bin` operand that way: not only a named list bin, but the result of any expression evaluating to a list. [`list_append`](#list_append) shows the pattern — its example takes the [`list_size`](#list_size) of the appended-to list, so the size counts the new element while the record keeps the original.

Two differences from the CDT List API

-   A list modify expression evaluates to the whole modified list. The matching [CDT List operation](https://aerospike.com/docs/develop/data-types/collections/list/operations) returns something narrower and operation-specific: `append` returns the new element count, and the remove-by operations return what `result_type` selects.
    
-   The single-element getters, [`list_get_by_index`](#list_get_by_index) and [`list_get_by_rank`](#list_get_by_rank), take a `type` argument in addition to `result_type`. A list element can be of any type, and an expression is strictly typed, so the getter has to declare the type it evaluates to. Reading an element of another type fails the expression.
    

Path expressions

List expressions such as [`list_get_by_value`](#list_get_by_value) can be used inside [path expression](https://aerospike.com/docs/develop/expressions/path/) filter contexts. For example, the IN-list membership pattern uses `list_get_by_value` with a loop variable to check whether a map key belongs to a given list of IDs. See the [path expressions performance](https://aerospike.com/docs/develop/expressions/path/performance) page for a detailed comparison of IN-list filtering approaches.

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

#### `list_append`

```python
list_append(context, policy, value, bin)
```

Description: Returns the list with `value` appended to the end. It does not create a bin that does not exist, unlike the [`append`](https://aerospike.com/docs/develop/data-types/collections/list/operations#append) CDT List 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` | `List policy` | 

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

 |
| `value` | `any` | 

Element to append to the list.

 |
| `bin` | `list` | 

List bin to operate on, or any expression that evaluates to a list.

 |

Returns: `list`

Introduced: 5.2.0.4

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

Example: Hypothetical filter using the list after appending `horror` to `tags` (modify expressions evaluate on a temporary list value).

-   [Java SDK](#tab-panel-1453)
-   [Python SDK](#tab-panel-1454)
-   [Rust](#tab-panel-1455)
-   [C#](#tab-panel-1456)
-   [Go](#tab-panel-1457)
-   [Node.js](#tab-panel-1458)
-   [C](#tab-panel-1459)
-   [Java](#tab-panel-1460)
-   [Python](#tab-panel-1461)

```java
String exp = "$.tags.append('horror').count() > 2";
```

```python
exp = "$.tags.append('horror').count() > 2"
```

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

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

use aerospike::ListPolicy;

let exp = gt(

    list_exp::size(

        list_exp::append(

            ListPolicy::default(),

            string_val("horror".into()),

            list_bin("tags".into()),

            &[]),

        &[]),

    int_val(2));
```

```csharp
Expression exp = Exp.Build(

  Exp.GT(

    ListExp.Size(

      ListExp.Append(ListPolicy.Default, Exp.Val("horror"), Exp.ListBin("tags"))),

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

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

exp := as.ExpGreater(

  as.ExpListSize(

    as.ExpListAppend(

      as.DefaultListPolicy(),

      as.ExpStringVal("horror"),

      as.ExpListBin("tags"),

    ),

  ),

  as.ExpIntVal(2),

)
```

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

const exp = Aerospike.exp

const filterExp = exp.gt(

  exp.lists.size(exp.lists.append(exp.binList('tags'), exp.str('horror'))),

  exp.int(2),

)
```

```c
as_list_policy pol;

as_list_policy_init(&pol);

as_exp_build(predexp,

  as_exp_cmp_gt(

    as_exp_list_size(

      NULL,

      as_exp_list_append(NULL, &pol, as_exp_str("horror"), as_exp_bin_list("tags"))),

    as_exp_int(2)));
```

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

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(

      ListExp.append(ListPolicy.Default, Exp.val("horror"), Exp.listBin("tags"))),

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

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

from aerospike_helpers.expressions.list import ListAppend, ListSize

exp = GT(ListSize(None, ListAppend(None, None, "horror", ListBin("tags"))), 2).compile()
```

---

#### `list_append_items`

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

Description: Returns the list with every element of `items` appended 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.

 |
| `policy` | `List policy` | 

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

 |
| `items` | `list` | 

Elements to append, as a list.

 |
| `bin` | `list` | 

List bin to operate on, or any expression that evaluates to a list.

 |

Returns: `list`

Introduced: 5.2.0.4

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

Example: Size check after appending two strings to `tags`.

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

```java
String exp = "$.tags.appendItems(['a', 'b']).count() > 3";
```

```python
exp = "$.tags.appendItems(['a', 'b']).count() > 3"
```

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

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

use aerospike::{ListPolicy, Value};

let exp = gt(

    list_exp::size(

        list_exp::append_items(

            ListPolicy::default(),

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

            list_bin("tags".into()),

            &[]),

        &[]),

    int_val(3));
```

```csharp
Expression exp = Exp.Build(

  Exp.GT(

    ListExp.Size(

      ListExp.AppendItems(

        ListPolicy.Default,

        Exp.Val(new List<string> { "a", "b" }),

        Exp.ListBin("tags"))),

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

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

exp := as.ExpGreater(

  as.ExpListSize(

    as.ExpListAppendItems(

      as.DefaultListPolicy(),

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

      as.ExpListBin("tags"),

    ),

  ),

  as.ExpIntVal(3),

)
```

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

const exp = Aerospike.exp

const filterExp = exp.gt(

  exp.lists.size(

    exp.lists.appendItems(exp.binList('tags'), exp.list(['a', 'b'])),

  ),

  exp.int(3),

)
```

```c
as_list_policy pol;

as_list_policy_init(&pol);

as_arraylist ab;

as_arraylist_init(&ab, 2, 2);

as_arraylist_append_str(&ab, "a");

as_arraylist_append_str(&ab, "b");

as_exp_build(predexp,

  as_exp_cmp_gt(

    as_exp_list_size(

      NULL,

      as_exp_list_append_items(

        NULL, &pol, as_exp_val(&ab), as_exp_bin_list("tags"))),

    as_exp_int(3)));

as_arraylist_destroy(&ab);
```

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

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(

      ListExp.appendItems(

        ListPolicy.Default,

        Exp.val(java.util.Arrays.asList("a", "b")),

        Exp.listBin("tags"))),

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

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

from aerospike_helpers.expressions.list import ListAppendItems, ListSize

exp = GT(ListSize(None, ListAppendItems(None, None, ["a", "b"], ListBin("tags"))), 3).compile()
```

---

#### `list_clear`

```python
list_clear(context, bin)
```

Description: Returns the list 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` | `list` | 

List bin to operate on, or any expression that evaluates to a list.

 |

Returns: `list`

Introduced: 5.2.0.4

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

Example: Cleared list has size `0`.

-   [Java SDK](#tab-panel-1471)
-   [Python SDK](#tab-panel-1472)
-   [Rust](#tab-panel-1473)
-   [C#](#tab-panel-1474)
-   [Go](#tab-panel-1475)
-   [Node.js](#tab-panel-1476)
-   [C](#tab-panel-1477)
-   [Java](#tab-panel-1478)
-   [Python](#tab-panel-1479)

```java
String exp = "$.tags.clear().count() == 0";
```

```python
exp = "$.tags.clear().count() == 0"
```

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

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

let exp = eq(list_exp::size(list_exp::clear(list_bin("tags".into()), &[]), &[]), int_val(0));
```

```csharp
Expression exp = Exp.Build(

  Exp.EQ(ListExp.Size(ListExp.Clear(Exp.ListBin("tags"))), Exp.Val(0)));
```

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

exp := as.ExpEq(

  as.ExpListSize(as.ExpListClear(as.ExpListBin("tags"))),

  as.ExpIntVal(0),

)
```

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

const exp = Aerospike.exp

const filterExp = exp.eq(exp.lists.size(exp.lists.clear(exp.binList('tags'))), exp.int(0))
```

```c
as_exp_build(predexp,

  as_exp_cmp_eq(

    as_exp_list_size(NULL, as_exp_list_clear(NULL, as_exp_bin_list("tags"))),

    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.eq(ListExp.size(ListExp.clear(Exp.listBin("tags"))), Exp.val(0)));
```

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

from aerospike_helpers.expressions.list import ListClear, ListSize

exp = Eq(ListSize(None, ListClear(None, ListBin("tags"))), 0).compile()
```

---

#### `list_increment`

```python
list_increment(context, policy, index, delta, bin)
```

Description: Returns the list with the element at `index` 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` | `List policy` | 

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

 |
| `index` | `integer` | 

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

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

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

 |
| `bin` | `list` | 

List bin to operate on, or any expression that evaluates to a list.

 |

Returns: `list`

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

Example: After adding `5` to `scores[0]`, the first element equals `100`.

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

```java
String exp = "($.scores.[0].add(5)).[0] == 100";
```

```python
exp = "($.scores.[0].add(5)).[0] == 100"
```

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

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

use aerospike::{ListPolicy, ListReturnType};

let exp = eq(

    list_exp::get_by_index(

        ListReturnType::Values,

        ExpType::INT,

        int_val(0),

        list_exp::increment(

            ListPolicy::default(),

            int_val(0),

            int_val(5),

            list_bin("scores".into()),

            &[]),

        &[]),

    int_val(100));
```

```csharp
Expression exp = Exp.Build(

  Exp.EQ(

    ListExp.GetByIndex(

      ListReturnType.VALUE,

      Exp.Type.INT,

      Exp.Val(0),

      ListExp.Increment(ListPolicy.Default, Exp.Val(0), Exp.Val(5), Exp.ListBin("scores"))),

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

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

exp := as.ExpEq(

  as.ExpListGetByIndex(

    as.ListReturnTypeValue,

    as.ExpTypeINT,

    as.ExpIntVal(0),

    as.ExpListIncrement(

      as.DefaultListPolicy(),

      as.ExpIntVal(0),

      as.ExpIntVal(5),

      as.ExpListBin("scores"),

    ),

  ),

  as.ExpIntVal(100),

)
```

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

const exp = Aerospike.exp

const lists = Aerospike.lists

const filterExp = exp.eq(

  exp.lists.getByIndex(

    exp.lists.increment(exp.binList('scores'), exp.int(5), exp.int(0)),

    exp.int(0),

    exp.type.INT,

    lists.returnType.VALUE,

  ),

  exp.int(100),

)
```

```c
as_list_policy pol;

as_list_policy_init(&pol);

as_exp_build(predexp,

  as_exp_cmp_eq(

    as_exp_list_get_by_index(

      NULL,

      AS_LIST_RETURN_VALUE,

      AS_EXP_TYPE_INT,

      as_exp_int(0),

      as_exp_list_increment(

        NULL, &pol, as_exp_int(0), as_exp_int(5), as_exp_bin_list("scores"))),

    as_exp_int(100)));
```

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

import com.aerospike.client.cdt.ListReturnType;

import com.aerospike.client.exp.Expression;

import com.aerospike.client.exp.Exp;

import com.aerospike.client.exp.ListExp;

Expression exp = Exp.build(

  Exp.eq(

    ListExp.getByIndex(

      ListReturnType.VALUE,

      Exp.Type.INT,

      Exp.val(0),

      ListExp.increment(ListPolicy.Default, Exp.val(0), Exp.val(5), Exp.listBin("scores"))),

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

```python
import aerospike

from aerospike_helpers.expressions import Eq, ListBin, ResultType

from aerospike_helpers.expressions.list import ListGetByIndex, ListIncrement

exp = Eq(

  ListGetByIndex(

    None,

    aerospike.LIST_RETURN_VALUE,

    ResultType.INTEGER,

    0,

    ListIncrement(None, None, 0, 5, ListBin("scores")),

  ),

  100,

).compile()
```

---

#### `list_insert`

```python
list_insert(context, policy, index, value, bin)
```

Description: Returns the list with `value` inserted 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.

 |
| `policy` | `List policy` | 

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

 |
| `index` | `integer` | 

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

 |
| `value` | `any` | 

Element to insert at `index`.

 |
| `bin` | `list` | 

List bin to operate on, or any expression that evaluates to a list.

 |

Returns: `list`

Introduced: 5.2.0.4

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

Example: Insert `prologue` at index `0` in `tags`, then require length > 1.

-   [Java SDK](#tab-panel-1489)
-   [Python SDK](#tab-panel-1490)
-   [Rust](#tab-panel-1491)
-   [C#](#tab-panel-1492)
-   [Go](#tab-panel-1493)
-   [Node.js](#tab-panel-1494)
-   [C](#tab-panel-1495)
-   [Java](#tab-panel-1496)
-   [Python](#tab-panel-1497)

```java
String exp = "$.tags.[0].insert('prologue').count() > 1";
```

```python
exp = "$.tags.[0].insert('prologue').count() > 1"
```

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

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

use aerospike::ListPolicy;

let exp = gt(

    list_exp::size(

        list_exp::insert(

            ListPolicy::default(),

            int_val(0),

            string_val("prologue".into()),

            list_bin("tags".into()),

            &[]),

        &[]),

    int_val(1));
```

```csharp
Expression exp = Exp.Build(

  Exp.GT(

    ListExp.Size(

      ListExp.Insert(ListPolicy.Default, Exp.Val(0), Exp.Val("prologue"), Exp.ListBin("tags"))),

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

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

exp := as.ExpGreater(

  as.ExpListSize(

    as.ExpListInsert(

      as.DefaultListPolicy(),

      as.ExpIntVal(0),

      as.ExpStringVal("prologue"),

      as.ExpListBin("tags"),

    ),

  ),

  as.ExpIntVal(1),

)
```

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

const exp = Aerospike.exp

const filterExp = exp.gt(

  exp.lists.size(

    exp.lists.insert(exp.binList('tags'), exp.str('prologue'), exp.int(0)),

  ),

  exp.int(1),

)
```

```c
as_list_policy pol;

as_list_policy_init(&pol);

as_exp_build(predexp,

  as_exp_cmp_gt(

    as_exp_list_size(

      NULL,

      as_exp_list_insert(

        NULL, &pol, as_exp_int(0), as_exp_str("prologue"), as_exp_bin_list("tags"))),

    as_exp_int(1)));
```

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

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(

      ListExp.insert(ListPolicy.Default, Exp.val(0), Exp.val("prologue"), Exp.listBin("tags"))),

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

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

from aerospike_helpers.expressions.list import ListInsert, ListSize

exp = GT(ListSize(None, ListInsert(None, None, 0, "prologue", ListBin("tags"))), 1).compile()
```

---

#### `list_insert_items`

```python
list_insert_items(context, policy, index, items, bin)
```

Description: Returns the list with every element of `items` inserted 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.

 |
| `policy` | `List policy` | 

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

 |
| `index` | `integer` | 

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

 |
| `items` | `list` | 

Elements to insert at `index`, as a list.

 |
| `bin` | `list` | 

List bin to operate on, or any expression that evaluates to a list.

 |

Returns: `list`

Introduced: 5.2.0.4

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

Example: Insert `[“x”,“y”]` at index `1` in `tags`.

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

```java
String exp = "$.tags.[1].insertItems(['x', 'y']).count() > 4";
```

```python
exp = "$.tags.[1].insertItems(['x', 'y']).count() > 4"
```

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

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

use aerospike::{ListPolicy, Value};

let exp = gt(

    list_exp::size(

        list_exp::insert_items(

            ListPolicy::default(),

            int_val(1),

            list_val(vec![Value::from("x"), Value::from("y")]),

            list_bin("tags".into()),

            &[]),

        &[]),

    int_val(4));
```

```csharp
Expression exp = Exp.Build(

  Exp.GT(

    ListExp.Size(

      ListExp.InsertItems(

        ListPolicy.Default,

        Exp.Val(1),

        Exp.Val(new List<string> { "x", "y" }),

        Exp.ListBin("tags"))),

    Exp.Val(4)));
```

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

exp := as.ExpGreater(

  as.ExpListSize(

    as.ExpListInsertItems(

      as.DefaultListPolicy(),

      as.ExpIntVal(1),

      as.ExpListVal(as.NewValue("x"), as.NewValue("y")),

      as.ExpListBin("tags"),

    ),

  ),

  as.ExpIntVal(4),

)
```

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

const exp = Aerospike.exp

const filterExp = exp.gt(

  exp.lists.size(

    exp.lists.insertItems(

      exp.binList('tags'),

      exp.list(['x', 'y']),

      exp.int(1),

    ),

  ),

  exp.int(4),

)
```

```c
as_list_policy pol;

as_list_policy_init(&pol);

as_arraylist xy;

as_arraylist_init(&xy, 2, 2);

as_arraylist_append_str(&xy, "x");

as_arraylist_append_str(&xy, "y");

as_exp_build(predexp,

  as_exp_cmp_gt(

    as_exp_list_size(

      NULL,

      as_exp_list_insert_items(

        NULL, &pol, as_exp_int(1), as_exp_val(&xy), as_exp_bin_list("tags"))),

    as_exp_int(4)));

as_arraylist_destroy(&xy);
```

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

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(

      ListExp.insertItems(

        ListPolicy.Default,

        Exp.val(1),

        Exp.val(java.util.Arrays.asList("x", "y")),

        Exp.listBin("tags"))),

    Exp.val(4)));
```

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

from aerospike_helpers.expressions.list import ListInsertItems, ListSize

exp = GT(

  ListSize(None, ListInsertItems(None, None, 1, ["x", "y"], ListBin("tags"))),

  4,

).compile()
```

---

#### `list_remove_by_index`

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

Description: Returns the list 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` | `list` | 

List bin to operate on, or any expression that evaluates to a list.

 |

Returns: `list`

Introduced: 5.2.0.4

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

Example: After removing index `0` from `tags`, length is `2`.

-   [Java SDK](#tab-panel-1507)
-   [Python SDK](#tab-panel-1508)
-   [Rust](#tab-panel-1509)
-   [C#](#tab-panel-1510)
-   [Go](#tab-panel-1511)
-   [Node.js](#tab-panel-1512)
-   [C](#tab-panel-1513)
-   [Java](#tab-panel-1514)
-   [Python](#tab-panel-1515)

```java
String exp = "$.tags.[0].remove().count() == 2";
```

```python
exp = "$.tags.[0].remove().count() == 2"
```

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

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

use aerospike::ListReturnType;

let exp = eq(

    list_exp::size(

        list_exp::remove_by_index(

            ListReturnType::None,

            int_val(0),

            list_bin("tags".into()),

            &[]),

        &[]),

    int_val(2));
```

```csharp
Expression exp = Exp.Build(

  Exp.EQ(ListExp.Size(ListExp.RemoveByIndex(Exp.Val(0), Exp.ListBin("tags"))), Exp.Val(2)));
```

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

exp := as.ExpEq(

  as.ExpListSize(as.ExpListRemoveByIndex(as.ExpIntVal(0), as.ExpListBin("tags"))),

  as.ExpIntVal(2),

)
```

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

const exp = Aerospike.exp

const filterExp = exp.eq(

  exp.lists.size(exp.lists.removeByIndex(exp.binList('tags'), exp.int(0))),

  exp.int(2),

)
```

```c
as_exp_build(predexp,

  as_exp_cmp_eq(

    as_exp_list_size(

      NULL, as_exp_list_remove_by_index(NULL, as_exp_int(0), as_exp_bin_list("tags"))),

    as_exp_int(2)));
```

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

import com.aerospike.client.exp.Exp;

import com.aerospike.client.exp.ListExp;

Expression exp = Exp.build(

  Exp.eq(

    ListExp.size(ListExp.removeByIndex(Exp.val(0), Exp.listBin("tags"))),

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

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

from aerospike_helpers.expressions.list import ListRemoveByIndex, ListSize

exp = Eq(ListSize(None, ListRemoveByIndex(None, 0, ListBin("tags"))), 2).compile()
```

---

#### `list_remove_by_index_range`

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

Description: Returns the list 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` | `list` | 

List bin to operate on, or any expression that evaluates to a list.

 |

Returns: `list`

Introduced: 5.2.0.4

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

Example: Remove two elements starting at index `0` from `tags`.

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

```java
String exp = "$.tags.[0:2].remove().count() > 0";
```

```python
exp = "$.tags.[0:2].remove().count() > 0"
```

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

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

use aerospike::ListReturnType;

let exp = gt(

    list_exp::size(

        list_exp::remove_by_index_range_count(

            ListReturnType::None,

            int_val(0),

            int_val(2),

            list_bin("tags".into()),

            &[]),

        &[]),

    int_val(0));
```

```csharp
Expression exp = Exp.Build(

  Exp.GT(

    ListExp.Size(

      ListExp.RemoveByIndexRange(

        ListReturnType.NONE, Exp.Val(0), Exp.Val(2), Exp.ListBin("tags"))),

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

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

exp := as.ExpGreater(

  as.ExpListSize(

    as.ExpListRemoveByIndexRangeCount(

      as.ListReturnTypeNone,

      as.ExpIntVal(0),

      as.ExpIntVal(2),

      as.ExpListBin("tags"),

    ),

  ),

  as.ExpIntVal(0),

)
```

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

const exp = Aerospike.exp

const filterExp = exp.gt(

  exp.lists.size(

    exp.lists.removeByIndexRange(exp.binList('tags'), exp.int(2), exp.int(0)),

  ),

  exp.int(0),

)
```

```c
as_exp_build(predexp,

  as_exp_cmp_gt(

    as_exp_list_size(

      NULL,

      as_exp_list_remove_by_index_range(

        NULL, AS_LIST_RETURN_NONE, as_exp_int(0), as_exp_int(2), as_exp_bin_list("tags"))),

    as_exp_int(0)));
```

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

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(

      ListExp.removeByIndexRange(

        ListReturnType.NONE, Exp.val(0), Exp.val(2), Exp.listBin("tags"))),

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

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

from aerospike_helpers.expressions.list import ListRemoveByIndexRange, ListSize

exp = GT(ListSize(None, ListRemoveByIndexRange(None, 0, 2, ListBin("tags"))), 0).compile()
```

---

#### `list_remove_by_index_range_to_end`

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

Description: Returns the list 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` | `list` | 

List bin to operate on, or any expression that evaluates to a list.

 |

Returns: `list`

Introduced: 5.2.0.4

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

Example: Remove from index `2` through end of `tags`; resulting list still has elements.

-   [Java SDK](#tab-panel-1525)
-   [Python SDK](#tab-panel-1526)
-   [Rust](#tab-panel-1527)
-   [C#](#tab-panel-1528)
-   [Go](#tab-panel-1529)
-   [Node.js](#tab-panel-1530)
-   [C](#tab-panel-1531)
-   [Java](#tab-panel-1532)
-   [Python](#tab-panel-1533)

```java
String exp = "$.tags.[2:].remove().count() > 0";
```

```python
exp = "$.tags.[2:].remove().count() > 0"
```

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

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

use aerospike::ListReturnType;

let exp = gt(

    list_exp::size(

        list_exp::remove_by_index_range(

            ListReturnType::None,

            int_val(2),

            list_bin("tags".into()),

            &[]),

        &[]),

    int_val(0));
```

```csharp
Expression exp = Exp.Build(

  Exp.GT(

    ListExp.Size(

      ListExp.RemoveByIndexRange(ListReturnType.NONE, Exp.Val(2), Exp.ListBin("tags"))),

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

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

exp := as.ExpGreater(

  as.ExpListSize(

    as.ExpListRemoveByIndexRange(

      as.ListReturnTypeNone,

      as.ExpIntVal(2),

      as.ExpListBin("tags"),

    ),

  ),

  as.ExpIntVal(0),

)
```

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

const exp = Aerospike.exp

const filterExp = exp.gt(

  exp.lists.size(exp.lists.removeByIndexRangeToEnd(exp.binList('tags'), exp.int(2))),

  exp.int(0),

)
```

```c
as_exp_build(predexp,

  as_exp_cmp_gt(

    as_exp_list_size(

      NULL,

      as_exp_list_remove_by_index_range_to_end(

        NULL, AS_LIST_RETURN_NONE, as_exp_int(2), as_exp_bin_list("tags"))),

    as_exp_int(0)));
```

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

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(

      ListExp.removeByIndexRange(ListReturnType.NONE, Exp.val(2), Exp.listBin("tags"))),

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

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

from aerospike_helpers.expressions.list import ListRemoveByIndexRangeToEnd, ListSize

exp = GT(ListSize(None, ListRemoveByIndexRangeToEnd(None, 2, ListBin("tags"))), 0).compile()
```

---

#### `list_remove_by_rank`

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

Description: Returns the list 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` | `list` | 

List bin to operate on, or any expression that evaluates to a list.

 |

Returns: `list`

Introduced: 5.2.0.4

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

Example: Remove the smallest score (rank `0`) and keep a non-empty list.

-   [Java SDK](#tab-panel-1534)
-   [Python SDK](#tab-panel-1535)
-   [Rust](#tab-panel-1536)
-   [C#](#tab-panel-1537)
-   [Go](#tab-panel-1538)
-   [Node.js](#tab-panel-1539)
-   [C](#tab-panel-1540)
-   [Java](#tab-panel-1541)
-   [Python](#tab-panel-1542)

```java
String exp = "$.scores.[#0].remove().count() > 0";
```

```python
exp = "$.scores.[#0].remove().count() > 0"
```

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

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

use aerospike::ListReturnType;

let exp = gt(

    list_exp::size(

        list_exp::remove_by_rank(

            ListReturnType::None,

            int_val(0),

            list_bin("scores".into()),

            &[]),

        &[]),

    int_val(0));
```

```csharp
Expression exp = Exp.Build(

  Exp.GT(

    ListExp.Size(ListExp.RemoveByRank(Exp.Val(0), Exp.ListBin("scores"))),

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

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

exp := as.ExpGreater(

  as.ExpListSize(as.ExpListRemoveByRank(as.ExpIntVal(0), as.ExpListBin("scores"))),

  as.ExpIntVal(0),

)
```

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

const exp = Aerospike.exp

const filterExp = exp.gt(

  exp.lists.size(exp.lists.removeByRank(exp.binList('scores'), exp.int(0))),

  exp.int(0),

)
```

```c
as_exp_build(predexp,

  as_exp_cmp_gt(

    as_exp_list_size(

      NULL, as_exp_list_remove_by_rank(NULL, as_exp_int(0), as_exp_bin_list("scores"))),

    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(ListExp.removeByRank(Exp.val(0), Exp.listBin("scores"))),

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

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

from aerospike_helpers.expressions.list import ListRemoveByRank, ListSize

exp = GT(ListSize(None, ListRemoveByRank(None, 0, ListBin("scores"))), 0).compile()
```

---

#### `list_remove_by_rank_range`

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

Description: Returns the list 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` | `list` | 

List bin to operate on, or any expression that evaluates to a list.

 |

Returns: `list`

Introduced: 5.2.0.4

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

Example: Remove the two smallest scores (rank `0`, count `2`).

-   [Java SDK](#tab-panel-1543)
-   [Python SDK](#tab-panel-1544)
-   [Rust](#tab-panel-1545)
-   [C#](#tab-panel-1546)
-   [Go](#tab-panel-1547)
-   [Node.js](#tab-panel-1548)
-   [C](#tab-panel-1549)
-   [Java](#tab-panel-1550)
-   [Python](#tab-panel-1551)

```java
String exp = "$.scores.[#0:2].remove().count() > 0";
```

```python
exp = "$.scores.[#0:2].remove().count() > 0"
```

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

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

use aerospike::ListReturnType;

let exp = gt(

    list_exp::size(

        list_exp::remove_by_rank_range_count(

            ListReturnType::None,

            int_val(0),

            int_val(2),

            list_bin("scores".into()),

            &[]),

        &[]),

    int_val(0));
```

```csharp
Expression exp = Exp.Build(

  Exp.GT(

    ListExp.Size(

      ListExp.RemoveByRankRange(

        ListReturnType.NONE, Exp.Val(0), Exp.Val(2), Exp.ListBin("scores"))),

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

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

exp := as.ExpGreater(

  as.ExpListSize(

    as.ExpListRemoveByRankRangeCount(

      as.ListReturnTypeNone,

      as.ExpIntVal(0),

      as.ExpIntVal(2),

      as.ExpListBin("scores"),

    ),

  ),

  as.ExpIntVal(0),

)
```

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

const exp = Aerospike.exp

const filterExp = exp.gt(

  exp.lists.size(

    exp.lists.removeByRankRange(exp.binList('scores'), exp.int(2), exp.int(0)),

  ),

  exp.int(0),

)
```

```c
as_exp_build(predexp,

  as_exp_cmp_gt(

    as_exp_list_size(

      NULL,

      as_exp_list_remove_by_rank_range(

        NULL, AS_LIST_RETURN_NONE, as_exp_int(0), as_exp_int(2), as_exp_bin_list("scores"))),

    as_exp_int(0)));
```

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

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(

      ListExp.removeByRankRange(

        ListReturnType.NONE, Exp.val(0), Exp.val(2), Exp.listBin("scores"))),

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

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

from aerospike_helpers.expressions.list import ListRemoveByRankRange, ListSize

exp = GT(ListSize(None, ListRemoveByRankRange(None, 0, 2, ListBin("scores"))), 0).compile()
```

---

#### `list_remove_by_rank_range_to_end`

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

Description: Returns the list 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` | `list` | 

List bin to operate on, or any expression that evaluates to a list.

 |

Returns: `list`

Introduced: 5.2.0.4

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

Example: Remove the two largest scores (rank `-2` through last).

-   [Java SDK](#tab-panel-1552)
-   [Python SDK](#tab-panel-1553)
-   [Rust](#tab-panel-1554)
-   [C#](#tab-panel-1555)
-   [Go](#tab-panel-1556)
-   [Node.js](#tab-panel-1557)
-   [C](#tab-panel-1558)
-   [Java](#tab-panel-1559)
-   [Python](#tab-panel-1560)

```java
String exp = "$.scores.[#-2:].remove().count() > 0";
```

```python
exp = "$.scores.[#-2:].remove().count() > 0"
```

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

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

use aerospike::ListReturnType;

let exp = gt(

    list_exp::size(

        list_exp::remove_by_rank_range(

            ListReturnType::None,

            int_val(-2),

            list_bin("scores".into()),

            &[]),

        &[]),

    int_val(0));
```

```csharp
Expression exp = Exp.Build(

  Exp.GT(

    ListExp.Size(

      ListExp.RemoveByRankRange(ListReturnType.NONE, Exp.Val(-2), Exp.ListBin("scores"))),

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

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

exp := as.ExpGreater(

  as.ExpListSize(

    as.ExpListRemoveByRankRange(

      as.ListReturnTypeNone,

      as.ExpIntVal(-2),

      as.ExpListBin("scores"),

    ),

  ),

  as.ExpIntVal(0),

)
```

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

const exp = Aerospike.exp

const filterExp = exp.gt(

  exp.lists.size(exp.lists.removeByRankRangeToEnd(exp.binList('scores'), exp.int(-2))),

  exp.int(0),

)
```

```c
as_exp_build(predexp,

  as_exp_cmp_gt(

    as_exp_list_size(

      NULL,

      as_exp_list_remove_by_rank_range_to_end(

        NULL, AS_LIST_RETURN_NONE, as_exp_int(-2), as_exp_bin_list("scores"))),

    as_exp_int(0)));
```

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

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(

      ListExp.removeByRankRange(ListReturnType.NONE, Exp.val(-2), Exp.listBin("scores"))),

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

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

from aerospike_helpers.expressions.list import ListRemoveByRankRangeToEnd, ListSize

exp = GT(ListSize(None, ListRemoveByRankRangeToEnd(None, -2, ListBin("scores"))), 0).compile()
```

---

#### `list_remove_by_rel_rank_range`

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

Description: Returns the list 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` | `list` | 

List bin to operate on, or any expression that evaluates to a list.

 |

Returns: `list`

Introduced: 5.2.0.4

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

Example: Remove at most two elements relative to value `10` (rank offset `0`) in `scores`.

-   [Java SDK](#tab-panel-1561)
-   [Python SDK](#tab-panel-1562)
-   [Rust](#tab-panel-1563)
-   [C#](#tab-panel-1564)
-   [Go](#tab-panel-1565)
-   [Node.js](#tab-panel-1566)
-   [C](#tab-panel-1567)
-   [Java](#tab-panel-1568)
-   [Python](#tab-panel-1569)

```java
String exp = "$.scores.[#0:1~10].remove().count() > 0";
```

```python
exp = "$.scores.[#0:1~10].remove().count() > 0"
```

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

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

use aerospike::ListReturnType;

let exp = gt(

    list_exp::size(

        list_exp::remove_by_value_relative_rank_range_count(

            ListReturnType::None,

            int_val(10),

            int_val(0),

            int_val(2),

            list_bin("scores".into()),

            &[]),

        &[]),

    int_val(0));
```

```csharp
Expression exp = Exp.Build(

  Exp.GT(

    ListExp.Size(

      ListExp.RemoveByValueRelativeRankRange(

        ListReturnType.NONE,

        Exp.Val(10),

        Exp.Val(0),

        Exp.Val(2),

        Exp.ListBin("scores"))),

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

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

exp := as.ExpGreater(

  as.ExpListSize(

    as.ExpListRemoveByValueRelativeRankRangeCount(

      as.ListReturnTypeNone,

      as.ExpIntVal(10),

      as.ExpIntVal(0),

      as.ExpIntVal(2),

      as.ExpListBin("scores"),

    ),

  ),

  as.ExpIntVal(0),

)
```

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

const exp = Aerospike.exp

const filterExp = exp.gt(

  exp.lists.size(

    exp.lists.removeByRelRankRange(

      exp.binList('scores'),

      exp.int(2),

      exp.int(0),

      exp.int(10),

    ),

  ),

  exp.int(0),

)
```

```c
as_exp_build(predexp,

  as_exp_cmp_gt(

    as_exp_list_size(

      NULL,

      as_exp_list_remove_by_rel_rank_range(

        NULL,

        AS_LIST_RETURN_NONE,

        as_exp_int(10),

        as_exp_int(0),

        as_exp_int(2),

        as_exp_bin_list("scores"))),

    as_exp_int(0)));
```

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

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(

      ListExp.removeByValueRelativeRankRange(

        ListReturnType.NONE,

        Exp.val(10),

        Exp.val(0),

        Exp.val(2),

        Exp.listBin("scores"))),

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

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

from aerospike_helpers.expressions.list import ListRemoveByValueRelRankRange, ListSize

exp = GT(

  ListSize(None, ListRemoveByValueRelRankRange(None, 10, 0, 2, ListBin("scores"))),

  0,

).compile()
```

---

#### `list_remove_by_rel_rank_range_to_end`

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

Description: Returns the list 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` | `list` | 

List bin to operate on, or any expression that evaluates to a list.

 |

Returns: `list`

Introduced: 5.2.0.4

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

Example: Remove by relative rank from value `10`, rank offset `0`, through end of `scores`.

-   [Java SDK](#tab-panel-1570)
-   [Python SDK](#tab-panel-1571)
-   [Rust](#tab-panel-1572)
-   [C#](#tab-panel-1573)
-   [Go](#tab-panel-1574)
-   [Node.js](#tab-panel-1575)
-   [C](#tab-panel-1576)
-   [Java](#tab-panel-1577)
-   [Python](#tab-panel-1578)

```java
String exp = "$.scores.[#0:~10].remove().count() > 0";
```

```python
exp = "$.scores.[#0:~10].remove().count() > 0"
```

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

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

use aerospike::ListReturnType;

let exp = gt(

    list_exp::size(

        list_exp::remove_by_value_relative_rank_range(

            ListReturnType::None,

            int_val(10),

            int_val(0),

            list_bin("scores".into()),

            &[]),

        &[]),

    int_val(0));
```

```csharp
Expression exp = Exp.Build(

  Exp.GT(

    ListExp.Size(

      ListExp.RemoveByValueRelativeRankRange(

        ListReturnType.NONE, Exp.Val(10), Exp.Val(0), Exp.ListBin("scores"))),

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

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

exp := as.ExpGreater(

  as.ExpListSize(

    as.ExpListRemoveByValueRelativeRankRange(

      as.ListReturnTypeNone,

      as.ExpIntVal(10),

      as.ExpIntVal(0),

      as.ExpListBin("scores"),

    ),

  ),

  as.ExpIntVal(0),

)
```

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

const exp = Aerospike.exp

const filterExp = exp.gt(

  exp.lists.size(

    exp.lists.removeByRelRankRangeToEnd(exp.binList('scores'), exp.int(0), exp.int(10)),

  ),

  exp.int(0),

)
```

```c
as_exp_build(predexp,

  as_exp_cmp_gt(

    as_exp_list_size(

      NULL,

      as_exp_list_remove_by_rel_rank_range_to_end(

        NULL, AS_LIST_RETURN_NONE, as_exp_int(10), as_exp_int(0), as_exp_bin_list("scores"))),

    as_exp_int(0)));
```

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

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(

      ListExp.removeByValueRelativeRankRange(

        ListReturnType.NONE, Exp.val(10), Exp.val(0), Exp.listBin("scores"))),

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

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

from aerospike_helpers.expressions.list import ListRemoveByValueRelRankToEnd, ListSize

exp = GT(

  ListSize(None, ListRemoveByValueRelRankToEnd(None, 10, 0, ListBin("scores"))),

  0,

).compile()
```

---

#### `list_remove_by_value`

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

Description: Returns the list with every element equal to `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 element equal to it is removed.

 |
| `bin` | `list` | 

List bin to operate on, or any expression that evaluates to a list.

 |

Returns: `list`

Introduced: 5.2.0.4

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

Example: After removing `draft` from `tags`, the list is still non-empty.

-   [Java SDK](#tab-panel-1579)
-   [Python SDK](#tab-panel-1580)
-   [Rust](#tab-panel-1581)
-   [C#](#tab-panel-1582)
-   [Go](#tab-panel-1583)
-   [Node.js](#tab-panel-1584)
-   [C](#tab-panel-1585)
-   [Java](#tab-panel-1586)
-   [Python](#tab-panel-1587)

```java
String exp = "$.tags.[='draft'].remove().count() > 0";
```

```python
exp = "$.tags.[='draft'].remove().count() > 0"
```

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

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

use aerospike::ListReturnType;

let exp = gt(

    list_exp::size(

        list_exp::remove_by_value(

            ListReturnType::None,

            string_val("draft".into()),

            list_bin("tags".into()),

            &[]),

        &[]),

    int_val(0));
```

```csharp
Expression exp = Exp.Build(

  Exp.GT(

    ListExp.Size(

      ListExp.RemoveByValue(ListReturnType.NONE, Exp.Val("draft"), Exp.ListBin("tags"))),

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

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

exp := as.ExpGreater(

  as.ExpListSize(

    as.ExpListRemoveByValue(

      as.ListReturnTypeNone,

      as.ExpStringVal("draft"),

      as.ExpListBin("tags"),

    ),

  ),

  as.ExpIntVal(0),

)
```

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

const exp = Aerospike.exp

const filterExp = exp.gt(

  exp.lists.size(exp.lists.removeByValue(exp.binList('tags'), exp.str('draft'))),

  exp.int(0),

)
```

```c
as_exp_build(predexp,

  as_exp_cmp_gt(

    as_exp_list_size(

      NULL,

      as_exp_list_remove_by_value(

        NULL, AS_LIST_RETURN_NONE, as_exp_str("draft"), as_exp_bin_list("tags"))),

    as_exp_int(0)));
```

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

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(

      ListExp.removeByValue(ListReturnType.NONE, Exp.val("draft"), Exp.listBin("tags"))),

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

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

from aerospike_helpers.expressions.list import ListRemoveByValue, ListSize

exp = GT(ListSize(None, ListRemoveByValue(None, "draft", ListBin("tags"))), 0).compile()
```

---

#### `list_remove_by_value_list`

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

Description: Returns the list with every element matching one of `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. Any element equal to one of these is removed.

 |
| `bin` | `list` | 

List bin to operate on, or any expression that evaluates to a list.

 |

Returns: `list`

Introduced: 5.2.0.4

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

Example: After removing values `a` and `b` from `tags`, size remains > 0.

-   [Java SDK](#tab-panel-1588)
-   [Python SDK](#tab-panel-1589)
-   [Rust](#tab-panel-1590)
-   [C#](#tab-panel-1591)
-   [Go](#tab-panel-1592)
-   [Node.js](#tab-panel-1593)
-   [C](#tab-panel-1594)
-   [Java](#tab-panel-1595)
-   [Python](#tab-panel-1596)

```java
String exp = "$.tags.[='a', 'b'].remove().count() > 0";
```

```python
exp = "$.tags.[='a', 'b'].remove().count() > 0"
```

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

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

use aerospike::{ListReturnType, Value};

let exp = gt(

    list_exp::size(

        list_exp::remove_by_value_list(

            ListReturnType::None,

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

            list_bin("tags".into()),

            &[]),

        &[]),

    int_val(0));
```

```csharp
Expression exp = Exp.Build(

  Exp.GT(

    ListExp.Size(

      ListExp.RemoveByValueList(

        ListReturnType.NONE,

        Exp.Val(new List<string> { "a", "b" }),

        Exp.ListBin("tags"))),

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

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

exp := as.ExpGreater(

  as.ExpListSize(

    as.ExpListRemoveByValueList(

      as.ListReturnTypeNone,

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

      as.ExpListBin("tags"),

    ),

  ),

  as.ExpIntVal(0),

)
```

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

const exp = Aerospike.exp

const filterExp = exp.gt(

  exp.lists.size(

    exp.lists.removeByValueList(exp.binList('tags'), exp.list(['a', 'b'])),

  ),

  exp.int(0),

)
```

```c
as_arraylist rm;

as_arraylist_init(&rm, 2, 2);

as_arraylist_append_str(&rm, "a");

as_arraylist_append_str(&rm, "b");

as_exp_build(predexp,

  as_exp_cmp_gt(

    as_exp_list_size(

      NULL,

      as_exp_list_remove_by_value_list(

        NULL, AS_LIST_RETURN_NONE, as_exp_val(&rm), as_exp_bin_list("tags"))),

    as_exp_int(0)));

as_arraylist_destroy(&rm);
```

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

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(

      ListExp.removeByValueList(

        ListReturnType.NONE,

        Exp.val(java.util.Arrays.asList("a", "b")),

        Exp.listBin("tags"))),

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

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

from aerospike_helpers.expressions.list import ListRemoveByValueList, ListSize

exp = GT(ListSize(None, ListRemoveByValueList(None, ["a", "b"], ListBin("tags"))), 0).compile()
```

---

#### `list_remove_by_value_range`

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

Description: Returns the list with every element in the interval `value_begin` ≤ x < `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` | `list` | 

List bin to operate on, or any expression that evaluates to a list.

 |

Returns: `list`

Introduced: 5.2.0.4

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

Example: Remove integer scores in `[10, 20)` and check the modified list still has elements.

-   [Java SDK](#tab-panel-1597)
-   [Python SDK](#tab-panel-1598)
-   [Rust](#tab-panel-1599)
-   [C#](#tab-panel-1600)
-   [Go](#tab-panel-1601)
-   [Node.js](#tab-panel-1602)
-   [C](#tab-panel-1603)
-   [Java](#tab-panel-1604)
-   [Python](#tab-panel-1605)

```java
String exp = "$.scores.[=10:20].remove().count() > 0";
```

```python
exp = "$.scores.[=10:20].remove().count() > 0"
```

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

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

use aerospike::ListReturnType;

let exp = gt(

    list_exp::size(

        list_exp::remove_by_value_range(

            ListReturnType::None,

            Some(int_val(10)),

            Some(int_val(20)),

            list_bin("scores".into()),

            &[]),

        &[]),

    int_val(0));
```

```csharp
Expression exp = Exp.Build(

  Exp.GT(

    ListExp.Size(

      ListExp.RemoveByValueRange(

        ListReturnType.NONE, Exp.Val(10), Exp.Val(20), Exp.ListBin("scores"))),

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

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

exp := as.ExpGreater(

  as.ExpListSize(

    as.ExpListRemoveByValueRange(

      as.ListReturnTypeNone,

      as.ExpIntVal(10),

      as.ExpIntVal(20),

      as.ExpListBin("scores"),

    ),

  ),

  as.ExpIntVal(0),

)
```

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

const exp = Aerospike.exp

const filterExp = exp.gt(

  exp.lists.size(

    exp.lists.removeByValueRange(exp.binList('scores'), exp.int(20), exp.int(10)),

  ),

  exp.int(0),

)
```

```c
as_exp_build(predexp,

  as_exp_cmp_gt(

    as_exp_list_size(

      NULL,

      as_exp_list_remove_by_value_range(

        NULL, AS_LIST_RETURN_NONE, as_exp_int(10), as_exp_int(20), as_exp_bin_list("scores"))),

    as_exp_int(0)));
```

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

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(

      ListExp.removeByValueRange(

        ListReturnType.NONE, Exp.val(10), Exp.val(20), Exp.listBin("scores"))),

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

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

from aerospike_helpers.expressions.list import ListRemoveByValueRange, ListSize

exp = GT(ListSize(None, ListRemoveByValueRange(None, 10, 20, ListBin("scores"))), 0).compile()
```

---

#### `list_set`

```python
list_set(context, index, value, bin)
```

Description: Returns the list with the element at `index` replaced by `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.

 |
| `index` | `integer` | 

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

 |
| `value` | `any` | 

Element to write at `index`, replacing what is there.

 |
| `bin` | `list` | 

List bin to operate on, or any expression that evaluates to a list.

 |

Returns: `list`

Introduced: 5.2.0.4

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

Example: After setting `scores[1]` to `99`, read back `99` at index `1`.

-   [Java SDK](#tab-panel-1606)
-   [Python SDK](#tab-panel-1607)
-   [Rust](#tab-panel-1608)
-   [C#](#tab-panel-1609)
-   [Go](#tab-panel-1610)
-   [Node.js](#tab-panel-1611)
-   [C](#tab-panel-1612)
-   [Java](#tab-panel-1613)
-   [Python](#tab-panel-1614)

```java
String exp = "($.scores.[1].setTo(99)).[1] == 99";
```

```python
exp = "($.scores.[1].setTo(99)).[1] == 99"
```

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

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

use aerospike::{ListPolicy, ListReturnType};

let exp = eq(

    list_exp::get_by_index(

        ListReturnType::Values,

        ExpType::INT,

        int_val(1),

        list_exp::set(

            ListPolicy::default(),

            int_val(1),

            int_val(99),

            list_bin("scores".into()),

            &[]),

        &[]),

    int_val(99));
```

```csharp
Expression exp = Exp.Build(

  Exp.EQ(

    ListExp.GetByIndex(

      ListReturnType.VALUE,

      Exp.Type.INT,

      Exp.Val(1),

      ListExp.Set(ListPolicy.Default, Exp.Val(1), Exp.Val(99), Exp.ListBin("scores"))),

    Exp.Val(99)));
```

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

exp := as.ExpEq(

  as.ExpListGetByIndex(

    as.ListReturnTypeValue,

    as.ExpTypeINT,

    as.ExpIntVal(1),

    as.ExpListSet(

      as.DefaultListPolicy(),

      as.ExpIntVal(1),

      as.ExpIntVal(99),

      as.ExpListBin("scores"),

    ),

  ),

  as.ExpIntVal(99),

)
```

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

const exp = Aerospike.exp

const lists = Aerospike.lists

const filterExp = exp.eq(

  exp.lists.getByIndex(

    exp.lists.set(exp.binList('scores'), exp.int(99), exp.int(1)),

    exp.int(1),

    exp.type.INT,

    lists.returnType.VALUE,

  ),

  exp.int(99),

)
```

```c
as_list_policy pol;

as_list_policy_init(&pol);

as_exp_build(predexp,

  as_exp_cmp_eq(

    as_exp_list_get_by_index(

      NULL,

      AS_LIST_RETURN_VALUE,

      AS_EXP_TYPE_INT,

      as_exp_int(1),

      as_exp_list_set(

        NULL, &pol, as_exp_int(1), as_exp_int(99), as_exp_bin_list("scores"))),

    as_exp_int(99)));
```

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

import com.aerospike.client.cdt.ListReturnType;

import com.aerospike.client.exp.Expression;

import com.aerospike.client.exp.Exp;

import com.aerospike.client.exp.ListExp;

Expression exp = Exp.build(

  Exp.eq(

    ListExp.getByIndex(

      ListReturnType.VALUE,

      Exp.Type.INT,

      Exp.val(1),

      ListExp.set(ListPolicy.Default, Exp.val(1), Exp.val(99), Exp.listBin("scores"))),

    Exp.val(99)));
```

```python
import aerospike

from aerospike_helpers.expressions import Eq, ListBin, ResultType

from aerospike_helpers.expressions.list import ListGetByIndex, ListSet

exp = Eq(

  ListGetByIndex(

    None,

    aerospike.LIST_RETURN_VALUE,

    ResultType.INTEGER,

    1,

    ListSet(None, None, 1, 99, ListBin("scores")),

  ),

  99,

).compile()
```

---

#### `list_sort`

```python
list_sort(context, sort_flags, bin)
```

Description: Returns the list in sorted order, as directed by `sort_flags`.

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.

 |
| `sort_flags` | `integer literal` | 

Sort flags: `0` sorts ascending, `2` sorts ascending and drops duplicate values.

 |
| `bin` | `list` | 

List bin to operate on, or any expression that evaluates to a list.

 |

Returns: `list`

Introduced: 5.2.0.4

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

Example: After the default ascending sort, the first element of `scores` is `0`.

-   [Java SDK](#tab-panel-1615)
-   [Python SDK](#tab-panel-1616)
-   [Rust](#tab-panel-1617)
-   [C#](#tab-panel-1618)
-   [Go](#tab-panel-1619)
-   [Node.js](#tab-panel-1620)
-   [C](#tab-panel-1621)
-   [Java](#tab-panel-1622)
-   [Python](#tab-panel-1623)

```java
String exp = "($.scores.sort()).[0] == 0";
```

```python
exp = "($.scores.sort()).[0] == 0"
```

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

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

use aerospike::{ListReturnType, ListSortFlags};

let exp = eq(

    list_exp::get_by_index(

        ListReturnType::Values,

        ExpType::INT,

        int_val(0),

        list_exp::sort(ListSortFlags::Default, list_bin("scores".into()), &[]),

        &[]),

    int_val(0));
```

```csharp
Expression exp = Exp.Build(

  Exp.EQ(

    ListExp.GetByIndex(

      ListReturnType.VALUE,

      Exp.Type.INT,

      Exp.Val(0),

      ListExp.Sort(ListSortFlags.DEFAULT, Exp.ListBin("scores"))),

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

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

exp := as.ExpEq(

  as.ExpListGetByIndex(

    as.ListReturnTypeValue,

    as.ExpTypeINT,

    as.ExpIntVal(0),

    as.ExpListSort(as.ListSortFlagsDefault, as.ExpListBin("scores")),

  ),

  as.ExpIntVal(0),

)
```

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

const exp = Aerospike.exp

const lists = Aerospike.lists

const filterExp = exp.eq(

  exp.lists.getByIndex(

    exp.lists.sort(exp.binList('scores'), lists.sortFlags.DEFAULT),

    exp.int(0),

    exp.type.INT,

    lists.returnType.VALUE,

  ),

  exp.int(0),

)
```

```c
as_exp_build(predexp,

  as_exp_cmp_eq(

    as_exp_list_get_by_index(

      NULL,

      AS_LIST_RETURN_VALUE,

      AS_EXP_TYPE_INT,

      as_exp_int(0),

      as_exp_list_sort(NULL, AS_LIST_SORT_DEFAULT, as_exp_bin_list("scores"))),

    as_exp_int(0)));
```

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

import com.aerospike.client.cdt.ListSortFlags;

import com.aerospike.client.exp.Expression;

import com.aerospike.client.exp.Exp;

import com.aerospike.client.exp.ListExp;

Expression exp = Exp.build(

  Exp.eq(

    ListExp.getByIndex(

      ListReturnType.VALUE,

      Exp.Type.INT,

      Exp.val(0),

      ListExp.sort(ListSortFlags.DEFAULT, Exp.listBin("scores"))),

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

```python
import aerospike

from aerospike_helpers.expressions import Eq, ListBin, ResultType

from aerospike_helpers.expressions.list import ListGetByIndex, ListSort

exp = Eq(

  ListGetByIndex(

    None,

    aerospike.LIST_RETURN_VALUE,

    ResultType.INTEGER,

    0,

    ListSort(None, aerospike.LIST_SORT_DEFAULT, ListBin("scores")),

  ),

  0,

).compile()
```

---

## Read

#### `list_get_by_index`

```python
list_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/list/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` | `list` | 

List bin to operate on, or any expression that evaluates to a list.

 |

Returns: `any`

Introduced: 5.2.0.4

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

Example: First element of integer list `scores` equals `42` (`LIST_RETURN_VALUE` with integer value type).

-   [Java SDK](#tab-panel-1624)
-   [Python SDK](#tab-panel-1625)
-   [Rust](#tab-panel-1626)
-   [C#](#tab-panel-1627)
-   [Go](#tab-panel-1628)
-   [Node.js](#tab-panel-1629)
-   [C](#tab-panel-1630)
-   [Java](#tab-panel-1631)
-   [Python](#tab-panel-1632)

```java
String exp = "$.scores.[0] == 42";
```

```python
exp = "$.scores.[0] == 42"
```

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

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

use aerospike::ListReturnType;

let exp = eq(

    list_exp::get_by_index(

        ListReturnType::Values,

        ExpType::INT,

        int_val(0),

        list_bin("scores".into()),

        &[]),

    int_val(42));
```

```csharp
Expression exp = Exp.Build(

  Exp.EQ(

    ListExp.GetByIndex(

      ListReturnType.VALUE, Exp.Type.INT, Exp.Val(0), Exp.ListBin("scores")),

    Exp.Val(42)));
```

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

exp := as.ExpEq(

  as.ExpListGetByIndex(

    as.ListReturnTypeValue,

    as.ExpTypeINT,

    as.ExpIntVal(0),

    as.ExpListBin("scores"),

  ),

  as.ExpIntVal(42),

)
```

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

const exp = Aerospike.exp

const lists = Aerospike.lists

const filterExp = exp.eq(

  exp.lists.getByIndex(

    exp.binList('scores'),

    exp.int(0),

    exp.type.INT,

    lists.returnType.VALUE,

  ),

  exp.int(42),

)
```

```c
as_exp_build(predexp,

  as_exp_cmp_eq(

    as_exp_list_get_by_index(

      NULL, AS_LIST_RETURN_VALUE, AS_EXP_TYPE_INT, as_exp_int(0), as_exp_bin_list("scores")),

    as_exp_int(42)));
```

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

import com.aerospike.client.exp.Expression;

import com.aerospike.client.exp.Exp;

import com.aerospike.client.exp.ListExp;

Expression exp = Exp.build(

  Exp.eq(

    ListExp.getByIndex(

      ListReturnType.VALUE, Exp.Type.INT, Exp.val(0), Exp.listBin("scores")),

    Exp.val(42)));
```

```python
import aerospike

from aerospike_helpers.expressions import Eq, ListBin, ResultType

from aerospike_helpers.expressions.list import ListGetByIndex

exp = Eq(

  ListGetByIndex(None, aerospike.LIST_RETURN_VALUE, ResultType.INTEGER, 0, ListBin("scores")),

  42,

).compile()
```

---

#### `list_get_by_index_range`

```python
list_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/list/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` | `list` | 

List bin to operate on, or any expression that evaluates to a list.

 |

Returns: `any`

Introduced: 5.2.0.4

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

Example: Exactly two elements starting at index `1` in `scores` (`LIST_RETURN_COUNT` with index `1` and count `2`).

-   [Java SDK](#tab-panel-1633)
-   [Python SDK](#tab-panel-1634)
-   [Rust](#tab-panel-1635)
-   [C#](#tab-panel-1636)
-   [Go](#tab-panel-1637)
-   [Node.js](#tab-panel-1638)
-   [C](#tab-panel-1639)
-   [Java](#tab-panel-1640)
-   [Python](#tab-panel-1641)

```java
String exp = "$.scores.[1:3].count() == 2";
```

```python
exp = "$.scores.[1:3].count() == 2"
```

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

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

use aerospike::ListReturnType;

let exp = eq(

    list_exp::get_by_index_range_count(

        ListReturnType::Count,

        int_val(1),

        int_val(2),

        list_bin("scores".into()),

        &[]),

    int_val(2));
```

```csharp
Expression exp = Exp.Build(

  Exp.EQ(

    ListExp.GetByIndexRange(

      ListReturnType.COUNT, Exp.Val(1), Exp.Val(2), Exp.ListBin("scores")),

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

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

exp := as.ExpEq(

  as.ExpListGetByIndexRangeCount(

    as.ListReturnTypeCount,

    as.ExpIntVal(1),

    as.ExpIntVal(2),

    as.ExpListBin("scores"),

  ),

  as.ExpIntVal(2),

)
```

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

const exp = Aerospike.exp

const lists = Aerospike.lists

const filterExp = exp.eq(

  exp.lists.getByIndexRange(

    exp.binList('scores'),

    exp.int(1),

    exp.int(2),

    lists.returnType.COUNT,

  ),

  exp.int(2),

)
```

```c
as_exp_build(predexp,

  as_exp_cmp_eq(

    as_exp_list_get_by_index_range(

      NULL, AS_LIST_RETURN_COUNT, as_exp_int(1), as_exp_int(2), as_exp_bin_list("scores")),

    as_exp_int(2)));
```

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

import com.aerospike.client.exp.Expression;

import com.aerospike.client.exp.Exp;

import com.aerospike.client.exp.ListExp;

Expression exp = Exp.build(

  Exp.eq(

    ListExp.getByIndexRange(

      ListReturnType.COUNT, Exp.val(1), Exp.val(2), Exp.listBin("scores")),

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

```python
import aerospike

from aerospike_helpers.expressions import Eq, ListBin

from aerospike_helpers.expressions.list import ListGetByIndexRange

exp = Eq(

  ListGetByIndexRange(None, aerospike.LIST_RETURN_COUNT, 1, 2, ListBin("scores")),

  2,

).compile()
```

---

#### `list_get_by_index_range_to_end`

```python
list_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/list/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` | `list` | 

List bin to operate on, or any expression that evaluates to a list.

 |

Returns: `any`

Introduced: 5.2.0.4

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

Example: Count of elements from index `2` through the end of `tags` (`LIST_RETURN_COUNT`).

-   [Java SDK](#tab-panel-1642)
-   [Python SDK](#tab-panel-1643)
-   [Rust](#tab-panel-1644)
-   [C#](#tab-panel-1645)
-   [Go](#tab-panel-1646)
-   [Node.js](#tab-panel-1647)
-   [C](#tab-panel-1648)
-   [Java](#tab-panel-1649)
-   [Python](#tab-panel-1650)

```java
String exp = "$.tags.[2:].count() == 1";
```

```python
exp = "$.tags.[2:].count() == 1"
```

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

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

use aerospike::ListReturnType;

let exp = eq(

    list_exp::get_by_index_range(

        ListReturnType::Count,

        int_val(2),

        list_bin("tags".into()),

        &[]),

    int_val(1));
```

```csharp
Expression exp = Exp.Build(

  Exp.EQ(

    ListExp.GetByIndexRange(ListReturnType.COUNT, Exp.Val(2), Exp.ListBin("tags")),

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

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

exp := as.ExpEq(

  as.ExpListGetByIndexRange(

    as.ListReturnTypeCount,

    as.ExpIntVal(2),

    as.ExpListBin("tags"),

  ),

  as.ExpIntVal(1),

)
```

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

const exp = Aerospike.exp

const lists = Aerospike.lists

const filterExp = exp.eq(

  exp.lists.getByIndexRangeToEnd(

    exp.binList('tags'),

    exp.int(2),

    lists.returnType.COUNT,

  ),

  exp.int(1),

)
```

```c
as_exp_build(predexp,

  as_exp_cmp_eq(

    as_exp_list_get_by_index_range_to_end(

      NULL, AS_LIST_RETURN_COUNT, as_exp_int(2), as_exp_bin_list("tags")),

    as_exp_int(1)));
```

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

import com.aerospike.client.exp.Expression;

import com.aerospike.client.exp.Exp;

import com.aerospike.client.exp.ListExp;

Expression exp = Exp.build(

  Exp.eq(

    ListExp.getByIndexRange(ListReturnType.COUNT, Exp.val(2), Exp.listBin("tags")),

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

```python
import aerospike

from aerospike_helpers.expressions import Eq, ListBin

from aerospike_helpers.expressions.list import ListGetByIndexRangeToEnd

exp = Eq(

  ListGetByIndexRangeToEnd(None, aerospike.LIST_RETURN_COUNT, 2, ListBin("tags")),

  1,

).compile()
```

---

#### `list_get_by_rank`

```python
list_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/list/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` | `list` | 

List bin to operate on, or any expression that evaluates to a list.

 |

Returns: `any`

Introduced: 5.2.0.4

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

Example: Smallest value in integer list `scores` is `12` (rank `0`, `LIST_RETURN_VALUE`).

-   [Java SDK](#tab-panel-1651)
-   [Python SDK](#tab-panel-1652)
-   [Rust](#tab-panel-1653)
-   [C#](#tab-panel-1654)
-   [Go](#tab-panel-1655)
-   [Node.js](#tab-panel-1656)
-   [C](#tab-panel-1657)
-   [Java](#tab-panel-1658)
-   [Python](#tab-panel-1659)

```java
String exp = "$.scores.[#0] == 12";
```

```python
exp = "$.scores.[#0] == 12"
```

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

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

use aerospike::ListReturnType;

let exp = eq(

    list_exp::get_by_rank(

        ListReturnType::Values,

        ExpType::INT,

        int_val(0),

        list_bin("scores".into()),

        &[]),

    int_val(12));
```

```csharp
Expression exp = Exp.Build(

  Exp.EQ(

    ListExp.GetByRank(ListReturnType.VALUE, Exp.Type.INT, Exp.Val(0), Exp.ListBin("scores")),

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

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

exp := as.ExpEq(

  as.ExpListGetByRank(

    as.ListReturnTypeValue,

    as.ExpTypeINT,

    as.ExpIntVal(0),

    as.ExpListBin("scores"),

  ),

  as.ExpIntVal(12),

)
```

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

const exp = Aerospike.exp

const lists = Aerospike.lists

const filterExp = exp.eq(

  exp.lists.getByRank(

    exp.binList('scores'),

    exp.int(0),

    exp.type.INT,

    lists.returnType.VALUE,

  ),

  exp.int(12),

)
```

```c
as_exp_build(predexp,

  as_exp_cmp_eq(

    as_exp_list_get_by_rank(

      NULL, AS_LIST_RETURN_VALUE, AS_EXP_TYPE_INT, as_exp_int(0), as_exp_bin_list("scores")),

    as_exp_int(12)));
```

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

import com.aerospike.client.exp.Expression;

import com.aerospike.client.exp.Exp;

import com.aerospike.client.exp.ListExp;

Expression exp = Exp.build(

  Exp.eq(

    ListExp.getByRank(ListReturnType.VALUE, Exp.Type.INT, Exp.val(0), Exp.listBin("scores")),

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

```python
import aerospike

from aerospike_helpers.expressions import Eq, ListBin, ResultType

from aerospike_helpers.expressions.list import ListGetByRank

exp = Eq(

  ListGetByRank(None, aerospike.LIST_RETURN_VALUE, ResultType.INTEGER, 0, ListBin("scores")),

  12,

).compile()
```

---

#### `list_get_by_rank_range`

```python
list_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/list/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` | `list` | 

List bin to operate on, or any expression that evaluates to a list.

 |

Returns: `any`

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

Example: Three smallest values in `scores` (rank `0`, count `3`, `LIST_RETURN_COUNT`).

-   [Java SDK](#tab-panel-1660)
-   [Python SDK](#tab-panel-1661)
-   [Rust](#tab-panel-1662)
-   [C#](#tab-panel-1663)
-   [Go](#tab-panel-1664)
-   [Node.js](#tab-panel-1665)
-   [C](#tab-panel-1666)
-   [Java](#tab-panel-1667)
-   [Python](#tab-panel-1668)

```java
String exp = "$.scores.[#0:3].count() == 3";
```

```python
exp = "$.scores.[#0:3].count() == 3"
```

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

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

use aerospike::ListReturnType;

let exp = eq(

    list_exp::get_by_rank_range_count(

        ListReturnType::Count,

        int_val(0),

        int_val(3),

        list_bin("scores".into()),

        &[]),

    int_val(3));
```

```csharp
Expression exp = Exp.Build(

  Exp.EQ(

    ListExp.GetByRankRange(

      ListReturnType.COUNT, Exp.Val(0), Exp.Val(3), Exp.ListBin("scores")),

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

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

exp := as.ExpEq(

  as.ExpListGetByRankRangeCount(

    as.ListReturnTypeCount,

    as.ExpIntVal(0),

    as.ExpIntVal(3),

    as.ExpListBin("scores"),

  ),

  as.ExpIntVal(3),

)
```

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

const exp = Aerospike.exp

const lists = Aerospike.lists

const filterExp = exp.eq(

  exp.lists.getByRankRange(

    exp.binList('scores'),

    exp.int(0),

    exp.int(3),

    lists.returnType.COUNT,

  ),

  exp.int(3),

)
```

```c
as_exp_build(predexp,

  as_exp_cmp_eq(

    as_exp_list_get_by_rank_range(

      NULL, AS_LIST_RETURN_COUNT, as_exp_int(0), as_exp_int(3), as_exp_bin_list("scores")),

    as_exp_int(3)));
```

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

import com.aerospike.client.exp.Expression;

import com.aerospike.client.exp.Exp;

import com.aerospike.client.exp.ListExp;

Expression exp = Exp.build(

  Exp.eq(

    ListExp.getByRankRange(

      ListReturnType.COUNT, Exp.val(0), Exp.val(3), Exp.listBin("scores")),

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

```python
import aerospike

from aerospike_helpers.expressions import Eq, ListBin

from aerospike_helpers.expressions.list import ListGetByRankRange

exp = Eq(

  ListGetByRankRange(None, aerospike.LIST_RETURN_COUNT, 0, 3, ListBin("scores")),

  3,

).compile()
```

---

#### `list_get_by_rank_range_to_end`

```python
list_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/list/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` | `list` | 

List bin to operate on, or any expression that evaluates to a list.

 |

Returns: `any`

Introduced: 5.2.0.4

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

Example: Two largest values in `scores` (rank `-2` through last, `LIST_RETURN_COUNT`).

-   [Java SDK](#tab-panel-1669)
-   [Python SDK](#tab-panel-1670)
-   [Rust](#tab-panel-1671)
-   [C#](#tab-panel-1672)
-   [Go](#tab-panel-1673)
-   [Node.js](#tab-panel-1674)
-   [C](#tab-panel-1675)
-   [Java](#tab-panel-1676)
-   [Python](#tab-panel-1677)

```java
String exp = "$.scores.[#-2:].count() == 2";
```

```python
exp = "$.scores.[#-2:].count() == 2"
```

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

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

use aerospike::ListReturnType;

let exp = eq(

    list_exp::get_by_rank_range(

        ListReturnType::Count,

        int_val(-2),

        list_bin("scores".into()),

        &[]),

    int_val(2));
```

```csharp
Expression exp = Exp.Build(

  Exp.EQ(

    ListExp.GetByRankRange(ListReturnType.COUNT, Exp.Val(-2), Exp.ListBin("scores")),

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

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

exp := as.ExpEq(

  as.ExpListGetByRankRange(

    as.ListReturnTypeCount,

    as.ExpIntVal(-2),

    as.ExpListBin("scores"),

  ),

  as.ExpIntVal(2),

)
```

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

const exp = Aerospike.exp

const lists = Aerospike.lists

const filterExp = exp.eq(

  exp.lists.getByRankRangeToEnd(

    exp.binList('scores'),

    exp.int(-2),

    lists.returnType.COUNT,

  ),

  exp.int(2),

)
```

```c
as_exp_build(predexp,

  as_exp_cmp_eq(

    as_exp_list_get_by_rank_range_to_end(

      NULL, AS_LIST_RETURN_COUNT, as_exp_int(-2), as_exp_bin_list("scores")),

    as_exp_int(2)));
```

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

import com.aerospike.client.exp.Expression;

import com.aerospike.client.exp.Exp;

import com.aerospike.client.exp.ListExp;

Expression exp = Exp.build(

  Exp.eq(

    ListExp.getByRankRange(ListReturnType.COUNT, Exp.val(-2), Exp.listBin("scores")),

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

```python
import aerospike

from aerospike_helpers.expressions import Eq, ListBin

from aerospike_helpers.expressions.list import ListGetByRankRangeToEnd

exp = Eq(

  ListGetByRankRangeToEnd(None, aerospike.LIST_RETURN_COUNT, -2, ListBin("scores")),

  2,

).compile()
```

---

#### `list_get_by_rel_rank_range`

```python
list_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/list/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` | `list` | 

List bin to operate on, or any expression that evaluates to a list.

 |

Returns: `any`

Introduced: 5.2.0.4

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

Example: Count of elements selected by relative rank range from value `15` (rank offset `0`, max `3` items) in `scores`.

-   [Java SDK](#tab-panel-1678)
-   [Python SDK](#tab-panel-1679)
-   [Rust](#tab-panel-1680)
-   [C#](#tab-panel-1681)
-   [Go](#tab-panel-1682)
-   [Node.js](#tab-panel-1683)
-   [C](#tab-panel-1684)
-   [Java](#tab-panel-1685)
-   [Python](#tab-panel-1686)

```java
String exp = "$.scores.[#0:2~15].count() > 0";
```

```python
exp = "$.scores.[#0:2~15].count() > 0"
```

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

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

use aerospike::ListReturnType;

let exp = gt(

    list_exp::get_by_value_relative_rank_range_count(

        ListReturnType::Count,

        int_val(15),

        int_val(0),

        int_val(3),

        list_bin("scores".into()),

        &[]),

    int_val(0));
```

```csharp
Expression exp = Exp.Build(

  Exp.GT(

    ListExp.GetByValueRelativeRankRange(

      ListReturnType.COUNT,

      Exp.Val(15),

      Exp.Val(0),

      Exp.Val(3),

      Exp.ListBin("scores")),

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

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

exp := as.ExpGreater(

  as.ExpListGetByValueRelativeRankRangeCount(

    as.ListReturnTypeCount,

    as.ExpIntVal(15),

    as.ExpIntVal(0),

    as.ExpIntVal(3),

    as.ExpListBin("scores"),

  ),

  as.ExpIntVal(0),

)
```

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

const exp = Aerospike.exp

const lists = Aerospike.lists

const filterExp = exp.gt(

  exp.lists.getByRelRankRange(

    exp.binList('scores'),

    exp.int(15),

    exp.int(0),

    exp.int(3),

    lists.returnType.COUNT,

  ),

  exp.int(0),

)
```

```c
as_exp_build(predexp,

  as_exp_cmp_gt(

    as_exp_list_get_by_rel_rank_range(

      NULL,

      AS_LIST_RETURN_COUNT,

      as_exp_int(15),

      as_exp_int(0),

      as_exp_int(3),

      as_exp_bin_list("scores")),

    as_exp_int(0)));
```

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

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.getByValueRelativeRankRange(

      ListReturnType.COUNT,

      Exp.val(15),

      Exp.val(0),

      Exp.val(3),

      Exp.listBin("scores")),

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

```python
import aerospike

from aerospike_helpers.expressions import GT, ListBin

from aerospike_helpers.expressions.list import ListGetByValueRelRankRange

exp = GT(

  ListGetByValueRelRankRange(

    None, aerospike.LIST_RETURN_COUNT, 15, 0, 3, ListBin("scores")

  ),

  0,

).compile()
```

---

#### `list_get_by_rel_rank_range_to_end`

```python
list_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/list/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` | `list` | 

List bin to operate on, or any expression that evaluates to a list.

 |

Returns: `any`

Introduced: 5.2.0.4

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

Example: Relative rank range from value `15` with rank offset `0` through end of `scores` (`LIST_RETURN_COUNT` > 0).

-   [Java SDK](#tab-panel-1687)
-   [Python SDK](#tab-panel-1688)
-   [Rust](#tab-panel-1689)
-   [C#](#tab-panel-1690)
-   [Go](#tab-panel-1691)
-   [Node.js](#tab-panel-1692)
-   [C](#tab-panel-1693)
-   [Java](#tab-panel-1694)
-   [Python](#tab-panel-1695)

```java
String exp = "$.scores.[#0:~15].count() > 0";
```

```python
exp = "$.scores.[#0:~15].count() > 0"
```

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

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

use aerospike::ListReturnType;

let exp = gt(

    list_exp::get_by_value_relative_rank_range(

        ListReturnType::Count,

        int_val(15),

        int_val(0),

        list_bin("scores".into()),

        &[]),

    int_val(0));
```

```csharp
Expression exp = Exp.Build(

  Exp.GT(

    ListExp.GetByValueRelativeRankRange(

      ListReturnType.COUNT, Exp.Val(15), Exp.Val(0), Exp.ListBin("scores")),

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

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

exp := as.ExpGreater(

  as.ExpListGetByValueRelativeRankRange(

    as.ListReturnTypeCount,

    as.ExpIntVal(15),

    as.ExpIntVal(0),

    as.ExpListBin("scores"),

  ),

  as.ExpIntVal(0),

)
```

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

const exp = Aerospike.exp

const lists = Aerospike.lists

const filterExp = exp.gt(

  exp.lists.getByRelRankRangeToEnd(

    exp.binList('scores'),

    exp.int(15),

    exp.int(0),

    lists.returnType.COUNT,

  ),

  exp.int(0),

)
```

```c
as_exp_build(predexp,

  as_exp_cmp_gt(

    as_exp_list_get_by_rel_rank_range_to_end(

      NULL, AS_LIST_RETURN_COUNT, as_exp_int(15), as_exp_int(0), as_exp_bin_list("scores")),

    as_exp_int(0)));
```

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

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.getByValueRelativeRankRange(

      ListReturnType.COUNT, Exp.val(15), Exp.val(0), Exp.listBin("scores")),

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

```python
import aerospike

from aerospike_helpers.expressions import GT, ListBin

from aerospike_helpers.expressions.list import ListGetByValueRelRankRangeToEnd

exp = GT(

  ListGetByValueRelRankRangeToEnd(

    None, aerospike.LIST_RETURN_COUNT, 15, 0, ListBin("scores")

  ),

  0,

).compile()
```

---

#### `list_get_by_value`

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

Description: Returns every element equal to `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/list/operations#return-types).

 |
| `value` | `any` | 

Value to match. Every element equal to it is selected.

 |
| `bin` | `list` | 

List bin to operate on, or any expression that evaluates to a list.

 |

Returns: `any`

Introduced: 5.2.0.4

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

Example: Filter where string list bin `tags` contains the value `fiction`, using `LIST_RETURN_EXISTS` (see also the [path expressions](https://aerospike.com/docs/develop/expressions/path/) IN-list membership pattern).

-   [Java SDK](#tab-panel-1696)
-   [Python SDK](#tab-panel-1697)
-   [Rust](#tab-panel-1698)
-   [C#](#tab-panel-1699)
-   [Go](#tab-panel-1700)
-   [Node.js](#tab-panel-1701)
-   [C](#tab-panel-1702)
-   [Java](#tab-panel-1703)
-   [Python](#tab-panel-1704)

```java
String exp = "$.tags.[='fiction'].exists()";
```

```python
exp = "$.tags.[='fiction'].exists()"
```

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

use aerospike::expressions::{list_bin, string_val};

use aerospike::ListReturnType;

let exp = list_exp::get_by_value(

    ListReturnType::Exists,

    string_val("fiction".into()),

    list_bin("tags".into()),

    &[]);
```

```csharp
Expression exp = Exp.Build(

  ListExp.GetByValue(ListReturnType.EXISTS, Exp.Val("fiction"), Exp.ListBin("tags")));
```

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

exp := as.ExpListGetByValue(

  as.ListReturnTypeExists,

  as.ExpStringVal("fiction"),

  as.ExpListBin("tags"),

)
```

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

const exp = Aerospike.exp

const lists = Aerospike.lists

const filterExp = exp.lists.getByValue(

  exp.binList('tags'),

  exp.str('fiction'),

  lists.returnType.EXISTS,

)
```

```c
as_exp_build(predexp,

  as_exp_list_get_by_value(

    NULL, AS_LIST_RETURN_EXISTS, as_exp_str("fiction"), as_exp_bin_list("tags")));
```

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

import com.aerospike.client.exp.Expression;

import com.aerospike.client.exp.Exp;

import com.aerospike.client.exp.ListExp;

Expression exp = Exp.build(

  ListExp.getByValue(ListReturnType.EXISTS, Exp.val("fiction"), Exp.listBin("tags")));
```

```python
import aerospike

from aerospike_helpers.expressions import ListBin

from aerospike_helpers.expressions.list import ListGetByValue

exp = ListGetByValue(

  None, aerospike.LIST_RETURN_EXISTS, "fiction", ListBin("tags")

).compile()
```

---

#### `list_get_by_value_list`

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

Description: Returns every element matching one of `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/list/operations#return-types).

 |
| `values` | `list` | 

Values to match, as a list. Every element equal to any of them is selected.

 |
| `bin` | `list` | 

List bin to operate on, or any expression that evaluates to a list.

 |

Returns: `any`

Introduced: 5.2.0.4

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

Example: Integer scores in `scores` where at least one value matches the list `[88, 94]` (using `LIST_RETURN_COUNT` > 0).

-   [Java SDK](#tab-panel-1705)
-   [Python SDK](#tab-panel-1706)
-   [Rust](#tab-panel-1707)
-   [C#](#tab-panel-1708)
-   [Go](#tab-panel-1709)
-   [Node.js](#tab-panel-1710)
-   [C](#tab-panel-1711)
-   [Java](#tab-panel-1712)
-   [Python](#tab-panel-1713)

```java
String exp = "$.scores.[=88, 94].count() > 0";
```

```python
exp = "$.scores.[=88, 94].count() > 0"
```

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

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

use aerospike::{ListReturnType, Value};

let exp = gt(

    list_exp::get_by_value_list(

        ListReturnType::Count,

        list_val(vec![Value::from(88), Value::from(94)]),

        list_bin("scores".into()),

        &[]),

    int_val(0));
```

```csharp
Expression exp = Exp.Build(

  Exp.GT(

    ListExp.GetByValueList(

      ListReturnType.COUNT,

      Exp.Val(new List<int> { 88, 94 }),

      Exp.ListBin("scores")),

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

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

exp := as.ExpGreater(

  as.ExpListGetByValueList(

    as.ListReturnTypeCount,

    as.ExpListVal(as.NewValue(88), as.NewValue(94)),

    as.ExpListBin("scores"),

  ),

  as.ExpIntVal(0),

)
```

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

const exp = Aerospike.exp

const lists = Aerospike.lists

const filterExp = exp.gt(

  exp.lists.getByValueList(

    exp.binList('scores'),

    exp.list([88, 94]),

    lists.returnType.COUNT,

  ),

  exp.int(0),

)
```

```c
as_arraylist vl;

as_arraylist_init(&vl, 2, 2);

as_arraylist_append_int64(&vl, 88);

as_arraylist_append_int64(&vl, 94);

as_exp_build(predexp,

  as_exp_cmp_gt(

    as_exp_list_get_by_value_list(

      NULL, AS_LIST_RETURN_COUNT, as_exp_val(&vl), as_exp_bin_list("scores")),

    as_exp_int(0)));

as_arraylist_destroy(&vl);
```

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

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.getByValueList(

      ListReturnType.COUNT,

      Exp.val(java.util.Arrays.asList(88, 94)),

      Exp.listBin("scores")),

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

```python
import aerospike

from aerospike_helpers.expressions import GT, ListBin

from aerospike_helpers.expressions.list import ListGetByValueList

exp = GT(

  ListGetByValueList(None, aerospike.LIST_RETURN_COUNT, [88, 94], ListBin("scores")),

  0,

).compile()
```

---

#### `list_get_by_value_range`

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

Description: Returns every element in the interval `value_begin` ≤ x < `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/list/operations#return-types).

 |
| `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` | `list` | 

List bin to operate on, or any expression that evaluates to a list.

 |

Returns: `any`

Introduced: 5.2.0.4

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

Example: Integer list `scores` with values in the half-open interval `[10, 50)` (using `LIST_RETURN_COUNT`).

-   [Java SDK](#tab-panel-1714)
-   [Python SDK](#tab-panel-1715)
-   [Rust](#tab-panel-1716)
-   [C#](#tab-panel-1717)
-   [Go](#tab-panel-1718)
-   [Node.js](#tab-panel-1719)
-   [C](#tab-panel-1720)
-   [Java](#tab-panel-1721)
-   [Python](#tab-panel-1722)

```java
String exp = "$.scores.[=10:50].count() > 0";
```

```python
exp = "$.scores.[=10:50].count() > 0"
```

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

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

use aerospike::ListReturnType;

let exp = gt(

    list_exp::get_by_value_range(

        ListReturnType::Count,

        Some(int_val(10)),

        Some(int_val(50)),

        list_bin("scores".into()),

        &[]),

    int_val(0));
```

```csharp
Expression exp = Exp.Build(

  Exp.GT(

    ListExp.GetByValueRange(

      ListReturnType.COUNT, Exp.Val(10), Exp.Val(50), Exp.ListBin("scores")),

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

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

exp := as.ExpGreater(

  as.ExpListGetByValueRange(

    as.ListReturnTypeCount,

    as.ExpIntVal(10),

    as.ExpIntVal(50),

    as.ExpListBin("scores"),

  ),

  as.ExpIntVal(0),

)
```

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

const exp = Aerospike.exp

const lists = Aerospike.lists

const filterExp = exp.gt(

  exp.lists.getByValueRange(

    exp.binList('scores'),

    exp.int(10),

    exp.int(50),

    lists.returnType.COUNT,

  ),

  exp.int(0),

)
```

```c
as_exp_build(predexp,

  as_exp_cmp_gt(

    as_exp_list_get_by_value_range(

      NULL, AS_LIST_RETURN_COUNT, as_exp_int(10), as_exp_int(50), as_exp_bin_list("scores")),

    as_exp_int(0)));
```

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

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.getByValueRange(

      ListReturnType.COUNT, Exp.val(10), Exp.val(50), Exp.listBin("scores")),

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

```python
import aerospike

from aerospike_helpers.expressions import GT, ListBin

from aerospike_helpers.expressions.list import ListGetByValueRange

exp = GT(

  ListGetByValueRange(None, aerospike.LIST_RETURN_COUNT, 10, 50, ListBin("scores")),

  0,

).compile()
```

---

#### `list_join`

```python
list_join(context, separator, bin)
```

Description: Returns the list’s string elements joined into one string. Every client also exposes a form that takes no `separator`, concatenating the elements with nothing between them.

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.

 |
| `separator` | `string` | 

String placed between elements. Omit it to join them with nothing in between.

 |
| `bin` | `list` | 

List bin to operate on, or any expression that evaluates to a list.

 |

Returns: `string`

Introduced: 8.2.0

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

Example: Filter records whose list bin `tags`, joined with `,`, equals `red,green,blue`.

-   [Java SDK](#tab-panel-1723)
-   [Python SDK](#tab-panel-1724)
-   [Rust](#tab-panel-1725)
-   [C#](#tab-panel-1726)
-   [Go](#tab-panel-1727)
-   [Node.js](#tab-panel-1728)
-   [C](#tab-panel-1729)
-   [Java](#tab-panel-1730)
-   [Python](#tab-panel-1731)

```java
String exp = "$.tags.join(',') == 'red,green,blue'";
```

```python
exp = "$.tags.join(',') == 'red,green,blue'"
```

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

use aerospike::expressions::{eq, list_bin, string_val};

let exp = eq(

    list_exp::join_by_separator(

        string_val(",".into()),

        list_bin("tags".into()),

        &[]),

    string_val("red,green,blue".into()));
```

```csharp
Expression exp = Exp.Build(

  Exp.EQ(

    ListExp.Join(Exp.Val(","), Exp.ListBin("tags")),

    Exp.Val("red,green,blue")));
```

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

exp := as.ExpEq(

  as.ExpListJoinBySeparator(as.ExpStringVal(","), as.ExpListBin("tags")),

  as.ExpStringVal("red,green,blue"),

)
```

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

const exp = Aerospike.exp

const filterExp = exp.eq(

  exp.lists.joinSeparator(exp.binList('tags'), ','),

  exp.str('red,green,blue'),

)
```

```c
as_exp_build(predexp,

  as_exp_cmp_eq(

    as_exp_list_join_separator(NULL, ",", as_exp_bin_list("tags")),

    as_exp_str("red,green,blue")));
```

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

import com.aerospike.client.exp.Exp;

import com.aerospike.client.exp.ListExp;

Expression exp = Exp.build(

  Exp.eq(

    ListExp.join(Exp.val(","), Exp.listBin("tags")),

    Exp.val("red,green,blue")));
```

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

from aerospike_helpers.expressions.list import ListJoin

exp = Eq(ListJoin(None, ",", ListBin("tags")), "red,green,blue").compile()
```

---

#### `list_size`

```python
list_size(context, bin)
```

Description: Returns the number of elements in the list.

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` | `list` | 

List bin to operate on, or any expression that evaluates to a list.

 |

Returns: `integer`

Introduced: 5.2.0.4

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

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

-   [Java SDK](#tab-panel-1732)
-   [Python SDK](#tab-panel-1733)
-   [Rust](#tab-panel-1734)
-   [C#](#tab-panel-1735)
-   [Go](#tab-panel-1736)
-   [Node.js](#tab-panel-1737)
-   [C](#tab-panel-1738)
-   [Java](#tab-panel-1739)
-   [Python](#tab-panel-1740)

```java
String exp = "$.tags:LIST.count() > 0";
```

```python
exp = "$.tags:LIST.count() > 0"
```

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

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

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

```csharp
Expression exp = Exp.Build(

  Exp.GT(ListExp.Size(Exp.ListBin("tags")), Exp.Val(0)));
```

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

exp := as.ExpGreater(

  as.ExpListSize(as.ExpListBin("tags")),

  as.ExpIntVal(0),

)
```

```javascript
const exp = Aerospike.exp

const filterExp = exp.gt(

  exp.lists.size(exp.binList('tags')),

  exp.int(0),

)
```

```c
as_exp_build(predexp,

  as_exp_cmp_gt(

    as_exp_list_size(NULL, as_exp_bin_list("tags")),

    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.listBin("tags")), Exp.val(0)));
```

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

from aerospike_helpers.expressions.list import ListSize

exp = GT(ListSize(None, ListBin("tags")), 0).compile()
```

---