---
title: "List bin operations"
description: "Guide to Aerospike list bin expressions for reading and modifying list-type bins in filter and operation pipelines."
---

# List bin operations

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

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

In each operation, the list operand (`list_bin_expr` in the argument tables) is any **list-valued expression**: not only a named list bin, but also the result of another expression that evaluates to a list. List operations **compose** by passing those values as the list input—for example, taking the size of a list after an append. 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/).

Composing expressions

The [`list_append`](https://aerospike.com/docs/develop/expressions/list-bin#list_append) reference includes an **Example** that wraps `ListExp.append` in `ListExp.size`—the same modify-then-read pattern described above. Many other **modify** operations show similar composition: their examples nest another list expression as the list operand (`list_bin_expr` in the arguments table).

This reference covers read operations (size, get-by-index, get-by-value, rank and range variants) and modify operations (`append`, `insert`, `remove`, `set`, `increment`, `sort`, and clear). List modify expressions evaluate on a **temporary** list value; they do not persist unless used in a write pipeline that stores the result.

-   List modify expressions differ from [CDT List operations](https://aerospike.com/docs/develop/data-types/collections/list/operations) in that they return the modified list-bin instead of a specified return type (for remove-by ops) or predefined return type (The CDT operation `append` returns an int for example).
    
-   List read expressions (other than `LIST_SIZE`) return a result based on their `integer_value` parameter.
    
    Calling single result CDT operations (e.g. `LIST_GET_BY_INDEX`) requires an `integer_value` when `integer_value` is `LIST_RETURN_VALUE` because a list element value can be any expression type.
    

Path expressions

List expressions such as `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 `ListExp.getByValue` 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.

## Modify

#### `list_append`

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

Description: Append `value` to list bin. `list_append` does not create a new bin if the specified bin does not exist, unlike the [`append`](https://aerospike.com/docs/develop/data-types/collections/list/operations#append) CDT List operation, which does create a new bin if the specified bin does not exist.

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

Returns: `list_bin`

Introduced: 5.2.0.4

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

-   [Java](#tab-panel-996)
-   [Python](#tab-panel-997)
-   [C](#tab-panel-998)
-   [Go](#tab-panel-999)
-   [C#](#tab-panel-1000)
-   [Node.js](#tab-panel-1001)

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

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

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

_ = as.ExpGreater(

  as.ExpListSize(

    as.ExpListAppend(

      as.DefaultListPolicy(),

      as.ExpStringVal("horror"),

      as.ExpListBin("tags"),

    ),

  ),

  as.ExpIntVal(2),

)
```

```csharp
Expression exp = Exp.Build(

  Exp.GT(

    ListExp.Size(

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

    Exp.Val(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),

)
```

---

#### `list_append_items`

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

Description: [Append](https://aerospike.com/develop/data-types/collections/list/operations#append_items) all elements in **values** to list bin.

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

Returns: `list_bin`

Introduced: 5.2.0.4

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

-   [Java](#tab-panel-1008)
-   [Python](#tab-panel-1009)
-   [C](#tab-panel-1010)
-   [Go](#tab-panel-1011)
-   [C#](#tab-panel-1012)
-   [Node.js](#tab-panel-1013)

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

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

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

_ = as.ExpGreater(

  as.ExpListSize(

    as.ExpListAppendItems(

      as.DefaultListPolicy(),

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

      as.ExpListBin("tags"),

    ),

  ),

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

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

)
```

---

#### `list_clear`

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

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

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

Returns: `list_bin`

Introduced: 5.2.0.4

Example: Cleared list has size `0`.

-   [Java](#tab-panel-1002)
-   [Python](#tab-panel-1003)
-   [C](#tab-panel-1004)
-   [Go](#tab-panel-1005)
-   [C#](#tab-panel-1006)
-   [Node.js](#tab-panel-1007)

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

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

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

_ = as.ExpEq(

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

  as.ExpIntVal(0),

)
```

```csharp
Expression exp = Exp.Build(

  Exp.EQ(ListExp.Size(ListExp.Clear(Exp.ListBin("tags"))), Exp.Val(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))
```

---

#### `list_increment`

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

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

Arguments: | Name | Type |
| --- | --- |
| `context` | `library_specific` |
| `policy` | `library_specific` |
| `index` | `integer_expr` |
| `delta` | `integer_expr` |
| `bin` | `list_bin_expr` |

Returns: `list_bin`

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

-   [Java](#tab-panel-1014)
-   [Python](#tab-panel-1015)
-   [C](#tab-panel-1016)
-   [Go](#tab-panel-1017)
-   [C#](#tab-panel-1018)
-   [Node.js](#tab-panel-1019)

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

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

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

_ = 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),

)
```

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

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

)
```

---

#### `list_insert`

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

Description: [Insert](https://aerospike.com/develop/data-types/collections/list/operations#insert) **value** at **index**.

Arguments: | Name | Type |
| --- | --- |
| `context` | `library_specific` |
| `policy` | `library_specific` |
| `index` | `integer_expr` |
| `value` | `expr` |
| `bin` | `list_bin_expr` |

Returns: `list_bin`

Introduced: 5.2.0.4

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

-   [Java](#tab-panel-1020)
-   [Python](#tab-panel-1021)
-   [C](#tab-panel-1022)
-   [Go](#tab-panel-1023)
-   [C#](#tab-panel-1024)
-   [Node.js](#tab-panel-1025)

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

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

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

_ = as.ExpGreater(

  as.ExpListSize(

    as.ExpListInsert(

      as.DefaultListPolicy(),

      as.ExpIntVal(0),

      as.ExpStringVal("prologue"),

      as.ExpListBin("tags"),

    ),

  ),

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

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

)
```

---

#### `list_insert_items`

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

Description: [Insert](https://aerospike.com/develop/data-types/collections/list/operations#insert) all elements in **values** at **index**.

Arguments: | Name | Type |
| --- | --- |
| `context` | `library_specific` |
| `policy` | `library_specific` |
| `index` | `integer_expr` |
| `values` | `list_expr` |
| `bin` | `list_bin_expr` |

Returns: `list_bin`

Introduced: 5.2.0.4

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

-   [Java](#tab-panel-1026)
-   [Python](#tab-panel-1027)
-   [C](#tab-panel-1028)
-   [Go](#tab-panel-1029)
-   [C#](#tab-panel-1030)
-   [Node.js](#tab-panel-1031)

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

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

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

_ = 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),

)
```

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

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

)
```

---

#### `list_remove_by_index`

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

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

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

Returns: `list_bin`

Introduced: 5.2.0.4

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

-   [Java](#tab-panel-1032)
-   [Python](#tab-panel-1033)
-   [C](#tab-panel-1034)
-   [Go](#tab-panel-1035)
-   [C#](#tab-panel-1036)
-   [Node.js](#tab-panel-1037)

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

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

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

_ = as.ExpEq(

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

  as.ExpIntVal(2),

)
```

```csharp
Expression exp = Exp.Build(

  Exp.EQ(ListExp.Size(ListExp.RemoveByIndex(Exp.Val(0), Exp.ListBin("tags"))), Exp.Val(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),

)
```

---

#### `list_remove_by_index_range`

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

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

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

Returns: `list_bin`

Introduced: 5.2.0.4

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

-   [Java](#tab-panel-1038)
-   [Python](#tab-panel-1039)
-   [C](#tab-panel-1040)
-   [Go](#tab-panel-1041)
-   [C#](#tab-panel-1042)
-   [Node.js](#tab-panel-1043)

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

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

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

_ = as.ExpGreater(

  as.ExpListSize(

    as.ExpListRemoveByIndexRangeCount(

      as.ListReturnTypeNone,

      as.ExpIntVal(0),

      as.ExpIntVal(2),

      as.ExpListBin("tags"),

    ),

  ),

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

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

)
```

---

#### `list_remove_by_index_range_to_end`

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

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

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

Returns: `list_bin`

Introduced: 5.2.0.4

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

-   [Java](#tab-panel-1044)
-   [Python](#tab-panel-1045)
-   [C](#tab-panel-1046)
-   [Go](#tab-panel-1047)
-   [C#](#tab-panel-1048)
-   [Node.js](#tab-panel-1049)

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

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

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

_ = as.ExpGreater(

  as.ExpListSize(

    as.ExpListRemoveByIndexRange(

      as.ListReturnTypeNone,

      as.ExpIntVal(2),

      as.ExpListBin("tags"),

    ),

  ),

  as.ExpIntVal(0),

)
```

```csharp
Expression exp = Exp.Build(

  Exp.GT(

    ListExp.Size(

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

    Exp.Val(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),

)
```

---

#### `list_remove_by_rank`

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

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

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

Returns: `list_bin`

Introduced: 5.2.0.4

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

-   [Java](#tab-panel-1050)
-   [Python](#tab-panel-1051)
-   [C](#tab-panel-1052)
-   [Go](#tab-panel-1053)
-   [C#](#tab-panel-1054)
-   [Node.js](#tab-panel-1055)

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

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

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

_ = as.ExpGreater(

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

  as.ExpIntVal(0),

)
```

```csharp
Expression exp = Exp.Build(

  Exp.GT(

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

    Exp.Val(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),

)
```

---

#### `list_remove_by_rank_range`

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

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

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

Returns: `list_bin`

Introduced: 5.2.0.4

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

-   [Java](#tab-panel-1056)
-   [Python](#tab-panel-1057)
-   [C](#tab-panel-1058)
-   [Go](#tab-panel-1059)
-   [C#](#tab-panel-1060)
-   [Node.js](#tab-panel-1061)

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

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

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

_ = as.ExpGreater(

  as.ExpListSize(

    as.ExpListRemoveByRankRangeCount(

      as.ListReturnTypeNone,

      as.ExpIntVal(0),

      as.ExpIntVal(2),

      as.ExpListBin("scores"),

    ),

  ),

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

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

)
```

---

#### `list_remove_by_rank_range_to_end`

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

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

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

Returns: `list_bin`

Introduced: 5.2.0.4

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

-   [Java](#tab-panel-1062)
-   [Python](#tab-panel-1063)
-   [C](#tab-panel-1064)
-   [Go](#tab-panel-1065)
-   [C#](#tab-panel-1066)
-   [Node.js](#tab-panel-1067)

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

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

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

_ = as.ExpGreater(

  as.ExpListSize(

    as.ExpListRemoveByRankRange(

      as.ListReturnTypeNone,

      as.ExpIntVal(-2),

      as.ExpListBin("scores"),

    ),

  ),

  as.ExpIntVal(0),

)
```

```csharp
Expression exp = Exp.Build(

  Exp.GT(

    ListExp.Size(

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

    Exp.Val(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),

)
```

---

#### `list_remove_by_rel_rank_range`

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

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

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

Returns: `list_bin`

Introduced: 5.2.0.4

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

-   [Java](#tab-panel-1068)
-   [Python](#tab-panel-1069)
-   [C](#tab-panel-1070)
-   [Go](#tab-panel-1071)
-   [C#](#tab-panel-1072)
-   [Node.js](#tab-panel-1073)

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

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

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

_ = as.ExpGreater(

  as.ExpListSize(

    as.ExpListRemoveByValueRelativeRankRangeCount(

      as.ListReturnTypeNone,

      as.ExpIntVal(10),

      as.ExpIntVal(0),

      as.ExpIntVal(2),

      as.ExpListBin("scores"),

    ),

  ),

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

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

)
```

---

#### `list_remove_by_rel_rank_range_to_end`

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

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

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

Returns: `list_bin`

Introduced: 5.2.0.4

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

-   [Java](#tab-panel-1074)
-   [Python](#tab-panel-1075)
-   [C](#tab-panel-1076)
-   [Go](#tab-panel-1077)
-   [C#](#tab-panel-1078)
-   [Node.js](#tab-panel-1079)

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

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

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

_ = as.ExpGreater(

  as.ExpListSize(

    as.ExpListRemoveByValueRelativeRankRange(

      as.ListReturnTypeNone,

      as.ExpIntVal(10),

      as.ExpIntVal(0),

      as.ExpListBin("scores"),

    ),

  ),

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

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

)
```

---

#### `list_remove_by_value`

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

Description: [Remove](https://aerospike.com/develop/data-types/collections/list/operations#remove_all_by_value) all **value** values from list.

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

Returns: `list_bin`

Introduced: 5.2.0.4

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

-   [Java](#tab-panel-1080)
-   [Python](#tab-panel-1081)
-   [C](#tab-panel-1082)
-   [Go](#tab-panel-1083)
-   [C#](#tab-panel-1084)
-   [Node.js](#tab-panel-1085)

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

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

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

_ = as.ExpGreater(

  as.ExpListSize(

    as.ExpListRemoveByValue(

      as.ListReturnTypeNone,

      as.ExpStringVal("draft"),

      as.ExpListBin("tags"),

    ),

  ),

  as.ExpIntVal(0),

)
```

```csharp
Expression exp = Exp.Build(

  Exp.GT(

    ListExp.Size(

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

    Exp.Val(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),

)
```

---

#### `list_remove_by_value_list`

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

Description: [Remove](https://aerospike.com/develop/data-types/collections/list/operations#remove_all_by_value_list) all elements with values in **value\_list** from list.

Arguments: | Name | Type |
| --- | --- |
| `context` | `library_specific` |
| `value` | `list_expr` |
| `bin` | `list_bin_expr` |

Returns: `list_bin`

Introduced: 5.2.0.4

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

-   [Java](#tab-panel-1086)
-   [Python](#tab-panel-1087)
-   [C](#tab-panel-1088)
-   [Go](#tab-panel-1089)
-   [C#](#tab-panel-1090)
-   [Node.js](#tab-panel-1091)

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

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

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

_ = as.ExpGreater(

  as.ExpListSize(

    as.ExpListRemoveByValueList(

      as.ListReturnTypeNone,

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

      as.ExpListBin("tags"),

    ),

  ),

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

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

)
```

---

#### `list_remove_by_value_range`

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

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

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

Returns: `list_bin`

Introduced: 5.2.0.4

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

-   [Java](#tab-panel-1092)
-   [Python](#tab-panel-1093)
-   [C](#tab-panel-1094)
-   [Go](#tab-panel-1095)
-   [C#](#tab-panel-1096)
-   [Node.js](#tab-panel-1097)

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

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

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

_ = as.ExpGreater(

  as.ExpListSize(

    as.ExpListRemoveByValueRange(

      as.ListReturnTypeNone,

      as.ExpIntVal(10),

      as.ExpIntVal(20),

      as.ExpListBin("scores"),

    ),

  ),

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

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

)
```

---

#### `list_set`

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

Description: [Set](https://aerospike.com/develop/data-types/collections/list/operations#set) element at **index** to **value**.

Arguments: | Name | Type |
| --- | --- |
| `context` | `library_specific` |
| `index` | `integer-expr` |
| `value` | `expr` |
| `bin` | `list_bin_expr` |

Returns: `list_bin`

Introduced: 5.2.0.4

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

-   [Java](#tab-panel-1098)
-   [Python](#tab-panel-1099)
-   [C](#tab-panel-1100)
-   [Go](#tab-panel-1101)
-   [C#](#tab-panel-1102)
-   [Node.js](#tab-panel-1103)

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

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

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

_ = 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),

)
```

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

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

)
```

---

#### `list_sort`

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

Description: [Sort](https://aerospike.com/develop/data-types/collections/list/operations#sort) list.

Arguments: | Name | Type |
| --- | --- |
| `context` | `library_specific` |
| `flag` | `integer` |
| `bin` | `list_bin_expr` |

Returns: `list_bin`

Introduced: 5.2.0.4

Example: After default ascending sort, the smallest element in `scores` is `0`.

-   [Java](#tab-panel-1104)
-   [Python](#tab-panel-1105)
-   [C](#tab-panel-1106)
-   [Go](#tab-panel-1107)
-   [C#](#tab-panel-1108)
-   [Node.js](#tab-panel-1109)

```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.getByRank(

      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 ListGetByRank, ListSort

exp = Eq(

  ListGetByRank(

    None,

    aerospike.LIST_RETURN_VALUE,

    ResultType.INTEGER,

    0,

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

  ),

  0,

).compile()
```

```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_list_sort(NULL, AS_LIST_SORT_DEFAULT, as_exp_bin_list("scores"))),

    as_exp_int(0)));
```

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

_ = as.ExpEq(

  as.ExpListGetByRank(

    as.ListReturnTypeValue,

    as.ExpTypeINT,

    as.ExpIntVal(0),

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

  ),

  as.ExpIntVal(0),

)
```

```csharp
Expression exp = Exp.Build(

  Exp.EQ(

    ListExp.GetByRank(

      ListReturnType.VALUE,

      Exp.Type.INT,

      Exp.Val(0),

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

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

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

const exp = Aerospike.exp

const lists = Aerospike.lists

const filterExp = exp.eq(

  exp.lists.getByRank(

    exp.lists.sort(exp.binList('scores'), 0),

    exp.int(0),

    exp.type.INT,

    lists.returnType.VALUE,

  ),

  exp.int(0),

)
```

---

## Read

#### `list_get_by_index`

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

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

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

Introduced: 5.2.0.4

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

-   [Java](#tab-panel-1110)
-   [Python](#tab-panel-1111)
-   [C](#tab-panel-1112)
-   [Go](#tab-panel-1113)
-   [C#](#tab-panel-1114)
-   [Node.js](#tab-panel-1115)

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

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

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

_ = as.ExpEq(

  as.ExpListGetByIndex(

    as.ListReturnTypeValue,

    as.ExpTypeINT,

    as.ExpIntVal(0),

    as.ExpListBin("scores"),

  ),

  as.ExpIntVal(42),

)
```

```csharp
Expression exp = Exp.Build(

  Exp.EQ(

    ListExp.GetByIndex(

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

    Exp.Val(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),

)
```

---

#### `list_get_by_index_range`

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

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

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

Introduced: 5.2.0.4

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

-   [Java](#tab-panel-1116)
-   [Python](#tab-panel-1117)
-   [C](#tab-panel-1118)
-   [Go](#tab-panel-1119)
-   [C#](#tab-panel-1120)
-   [Node.js](#tab-panel-1121)

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

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

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

_ = as.ExpEq(

  as.ExpListGetByIndexRangeCount(

    as.ListReturnTypeCount,

    as.ExpIntVal(1),

    as.ExpIntVal(2),

    as.ExpListBin("scores"),

  ),

  as.ExpIntVal(2),

)
```

```csharp
Expression exp = Exp.Build(

  Exp.EQ(

    ListExp.GetByIndexRange(

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

    Exp.Val(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),

)
```

---

#### `list_get_by_index_range_to_end`

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

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

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

Introduced: 5.2.0.4

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

-   [Java](#tab-panel-1122)
-   [Python](#tab-panel-1123)
-   [C](#tab-panel-1124)
-   [Go](#tab-panel-1125)
-   [C#](#tab-panel-1126)
-   [Node.js](#tab-panel-1127)

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

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

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

_ = as.ExpEq(

  as.ExpListGetByIndexRange(

    as.ListReturnTypeCount,

    as.ExpIntVal(2),

    as.ExpListBin("tags"),

  ),

  as.ExpIntVal(1),

)
```

```csharp
Expression exp = Exp.Build(

  Exp.EQ(

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

    Exp.Val(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),

)
```

---

#### `list_get_by_rank`

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

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

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

Introduced: 5.2.0.4

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

-   [Java](#tab-panel-1128)
-   [Python](#tab-panel-1129)
-   [C](#tab-panel-1130)
-   [Go](#tab-panel-1131)
-   [C#](#tab-panel-1132)
-   [Node.js](#tab-panel-1133)

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

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

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

_ = as.ExpEq(

  as.ExpListGetByRank(

    as.ListReturnTypeValue,

    as.ExpTypeINT,

    as.ExpIntVal(0),

    as.ExpListBin("scores"),

  ),

  as.ExpIntVal(12),

)
```

```csharp
Expression exp = Exp.Build(

  Exp.EQ(

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

    Exp.Val(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),

)
```

---

#### `list_get_by_rank_range`

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

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

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

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

-   [Java](#tab-panel-1134)
-   [Python](#tab-panel-1135)
-   [C](#tab-panel-1136)
-   [Go](#tab-panel-1137)
-   [C#](#tab-panel-1138)
-   [Node.js](#tab-panel-1139)

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

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

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

_ = as.ExpEq(

  as.ExpListGetByRankRangeCount(

    as.ListReturnTypeCount,

    as.ExpIntVal(0),

    as.ExpIntVal(3),

    as.ExpListBin("scores"),

  ),

  as.ExpIntVal(3),

)
```

```csharp
Expression exp = Exp.Build(

  Exp.EQ(

    ListExp.GetByRankRange(

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

    Exp.Val(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),

)
```

---

#### `list_get_by_rank_range_to_end`

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

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

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

Introduced: 5.2.0.4

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

-   [Java](#tab-panel-1140)
-   [Python](#tab-panel-1141)
-   [C](#tab-panel-1142)
-   [Go](#tab-panel-1143)
-   [C#](#tab-panel-1144)
-   [Node.js](#tab-panel-1145)

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

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

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

_ = as.ExpEq(

  as.ExpListGetByRankRange(

    as.ListReturnTypeCount,

    as.ExpIntVal(-2),

    as.ExpListBin("scores"),

  ),

  as.ExpIntVal(2),

)
```

```csharp
Expression exp = Exp.Build(

  Exp.EQ(

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

    Exp.Val(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),

)
```

---

#### `list_get_by_rel_rank_range`

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

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

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

Introduced: 5.2.0.4

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

-   [Java](#tab-panel-1146)
-   [Python](#tab-panel-1147)
-   [C](#tab-panel-1148)
-   [Go](#tab-panel-1149)
-   [C#](#tab-panel-1150)
-   [Node.js](#tab-panel-1151)

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

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

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

_ = as.ExpGreater(

  as.ExpListGetByValueRelativeRankRangeCount(

    as.ListReturnTypeCount,

    as.ExpIntVal(15),

    as.ExpIntVal(0),

    as.ExpIntVal(3),

    as.ExpListBin("scores"),

  ),

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

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

)
```

---

#### `list_get_by_rel_rank_range_to_end`

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

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

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

Introduced: 5.2.0.4

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

-   [Java](#tab-panel-1152)
-   [Python](#tab-panel-1153)
-   [C](#tab-panel-1154)
-   [Go](#tab-panel-1155)
-   [C#](#tab-panel-1156)
-   [Node.js](#tab-panel-1157)

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

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

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

_ = as.ExpGreater(

  as.ExpListGetByValueRelativeRankRange(

    as.ListReturnTypeCount,

    as.ExpIntVal(15),

    as.ExpIntVal(0),

    as.ExpListBin("scores"),

  ),

  as.ExpIntVal(0),

)
```

```csharp
Expression exp = Exp.Build(

  Exp.GT(

    ListExp.GetByValueRelativeRankRange(

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

    Exp.Val(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),

)
```

---

#### `list_get_by_value`

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

Description: [Get](https://aerospike.com/develop/data-types/collections/list/operations#get_all_by_value) all **value** values from list.

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

Introduced: 5.2.0.4

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

-   [Java](#tab-panel-1158)
-   [Python](#tab-panel-1159)
-   [C](#tab-panel-1160)
-   [Go](#tab-panel-1161)
-   [C#](#tab-panel-1162)
-   [Node.js](#tab-panel-1163)

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

```c
as_exp_build(predexp,

  as_exp_cmp_eq(

    as_exp_list_get_by_value(

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

    as_exp_bool(true)));
```

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

_ = as.ExpListGetByValue(

  as.ListReturnTypeExists,

  as.ExpStringVal("fiction"),

  as.ExpListBin("tags"),

)
```

```csharp
Expression exp = Exp.Build(

  ListExp.GetByValue(ListReturnType.EXISTS, Exp.Val("fiction"), Exp.ListBin("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,

)
```

---

#### `list_get_by_value_list`

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

Description: [Get](https://aerospike.com/develop/data-types/collections/list/operations#get_all_by_value_list) all elements with values in **values** from list.

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

Introduced: 5.2.0.4

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

-   [Java](#tab-panel-1164)
-   [Python](#tab-panel-1165)
-   [C](#tab-panel-1166)
-   [Go](#tab-panel-1167)
-   [C#](#tab-panel-1168)
-   [Node.js](#tab-panel-1169)

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

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

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

_ = as.ExpGreater(

  as.ExpListGetByValueList(

    as.ListReturnTypeCount,

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

    as.ExpListBin("scores"),

  ),

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

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

)
```

---

#### `list_get_by_value_range`

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

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

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

Introduced: 5.2.0.4

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

-   [Java](#tab-panel-1170)
-   [Python](#tab-panel-1171)
-   [C](#tab-panel-1172)
-   [Go](#tab-panel-1173)
-   [C#](#tab-panel-1174)
-   [Node.js](#tab-panel-1175)

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

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

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

_ = as.ExpGreater(

  as.ExpListGetByValueRange(

    as.ListReturnTypeCount,

    as.ExpIntVal(10),

    as.ExpIntVal(50),

    as.ExpListBin("scores"),

  ),

  as.ExpIntVal(0),

)
```

```csharp
Expression exp = Exp.Build(

  Exp.GT(

    ListExp.GetByValueRange(

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

    Exp.Val(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),

)
```

---

#### `list_size`

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

Description: [Get](https://aerospike.com/develop/data-types/collections/list/operations#size) list element count.

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

Returns: `integer_bin`

Introduced: 5.2.0.4

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

-   [Java](#tab-panel-1176)
-   [Python](#tab-panel-1177)
-   [C](#tab-panel-1178)
-   [Go](#tab-panel-1179)
-   [C#](#tab-panel-1180)
-   [Node.js](#tab-panel-1181)

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

```c
as_exp_build(predexp,

  as_exp_cmp_gt(

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

    as_exp_int(0)));
```

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

_ = as.ExpGreater(

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

  as.ExpIntVal(0),

)
```

```csharp
Expression exp = Exp.Build(

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

```javascript
const exp = Aerospike.exp

const filterExp = exp.gt(

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

  exp.int(0),

)
```

---