stargate / data-api

JSON document API for Apache Cassandra (formerly known as JSON API)
https://stargate.io
Apache License 2.0
14 stars 16 forks source link

[Tables] Sorted `find` returns a nextPageState that cannot be subsequently used (because: no pagination with sort) #1735

Open hemidactylus opened 4 days ago

hemidactylus commented 4 days ago

Running a find on a table with a regular (non-ANN) sort clause returns up to 20 results, sorted as expected, but also returns a non-null nextPageState token. Using this as the pageState of a second request, predictably, gives an error as follows:

Request invalid: Request invalid: field 'command.options.pageState' value 
"FindCommand[filterClause=FilterClause[logicalExpression=LogicalExpression{logicalRelation='AND', 
totalComparisonExpressionCount=2, logicalExpressions=[], comparisonExpressions=
[ComparisonExpression{path='p_ascii', filterOperations=[ValueComparisonOperation[operator=EQ, 
operand=JsonLiteral{type=STRING, value(String)=A}]], dbFilters=null}, 
ComparisonExpression{path='p_bigint', filterOperations=[ValueComparisonOperation[operator=EQ, 
operand=JsonLiteral{type=NUMBER, value(BigDecimal)=100}]], dbFilters=null}]}], 
projectionDefinition=null, sortClause=SortClause[sortExpressions=[SortExpression[path=p_int, 
ascending=false, vector=null, vectorize=null]]], options=Options[limit=251, skip=null, 
pageState=AAgABAAAAOYBAYDn8H///+s=, includeSimilarity=false, 
includeSortVector=false]]" not valid. Problem: pageState is not supported with sort clause. 
(COMMAND_FIELD_INVALID)

In particular:

  1. this would mislead a CURL user who, seeing that token, would use it to get more stuff (we know in this case "pagination" is a manual affair involving skip+limit, and "to be discouraged" somewhat because of resource waste, in-mem sorting, etc)
  2. for clients this is a big nuisance since the find method for client does follow page after page on the user's behalf, so right now the clients error like seen above.
amorton commented 2 days ago

@hemidactylus can you provide the request that generated the error ? Also, is is possible to include the response from the API so it is easier to see the error

If there is a sort clause that we can serve using the clustering keys, we can provide the pagnation, but if the sorting is in memory we cannot. This is not great, but is what it is for now until we get expanded order by in the DB.

hemidactylus commented 2 days ago

Sure, here we go (caution: long payloads. I could not reproduce with a super-simple table - perhaps without clustering columns this does not happen? So I have to paste the exact table schema used in my test, which has several columns. But the issue is happening all right...)

createTable:

{
    "createTable": {
        "definition": {
            "columns": {
                "p_ascii": {
                    "type": "ascii"
                },
                "p_bigint": {
                    "type": "bigint"
                },
                "p_blob": {
                    "type": "blob"
                },
                "p_boolean": {
                    "type": "boolean"
                },
                "p_date": {
                    "type": "date"
                },
                "p_decimal": {
                    "type": "decimal"
                },
                "p_double": {
                    "type": "double"
                },
                "p_double_minf": {
                    "type": "double"
                },
                "p_double_pinf": {
                    "type": "double"
                },
                "p_duration": {
                    "type": "duration"
                },
                "p_float": {
                    "type": "float"
                },
                "p_float_nan": {
                    "type": "float"
                },
                "p_inet": {
                    "type": "inet"
                },
                "p_int": {
                    "type": "int"
                },
                "p_list_int": {
                    "type": "list",
                    "valueType": "int"
                },
                "p_map_text_text": {
                    "keyType": "text",
                    "type": "map",
                    "valueType": "text"
                },
                "p_set_int": {
                    "type": "set",
                    "valueType": "int"
                },
                "p_smallint": {
                    "type": "smallint"
                },
                "p_text": {
                    "type": "text"
                },
                "p_text_nulled": {
                    "type": "text"
                },
                "p_text_omitted": {
                    "type": "text"
                },
                "p_time": {
                    "type": "time"
                },
                "p_timestamp": {
                    "type": "timestamp"
                },
                "p_tinyint": {
                    "type": "tinyint"
                },
                "p_uuid": {
                    "type": "uuid"
                },
                "p_varint": {
                    "type": "varint"
                },
                "p_vector": {
                    "dimension": 3,
                    "type": "vector"
                }
            },
            "primaryKey": {
                "partitionBy": [
                    "p_ascii",
                    "p_bigint"
                ],
                "partitionSort": {
                    "p_boolean": -1,
                    "p_int": 1
                }
            }
        },
        "name": "test_table_all_returns"
    }
}

insert 50 rows

{
    "insertMany": {
        "documents": [
            {
                "p_ascii": "A",
                "p_bigint": 100,
                "p_boolean": true,
                "p_float": 200.2,
                "p_int": 200,
                "p_list_int": [
                    203,
                    1,
                    200
                ],
                "p_map_text_text": {
                    "a": "V200A",
                    "b": "V200B"
                },
                "p_set_int": [
                    400,
                    300,
                    200
                ],
                "p_text": "b200",
                "p_timestamp": "1200-01-01T01:01:01.000Z"
            },
            {
                "p_ascii": "A",
                "p_bigint": 100,
                "p_boolean": false,
                "p_float": 201.2,
                "p_int": 201,
                "p_list_int": [
                    204,
                    1,
                    201
                ],
                "p_map_text_text": {
                    "a": "V201A",
                    "b": "V201B"
                },
                "p_set_int": [
                    401,
                    300,
                    201
                ],
                "p_text": "b201",
                "p_timestamp": "1201-01-01T01:01:01.000Z"
            },
            {
                "p_ascii": "A",
                "p_bigint": 100,
                "p_boolean": true,
                "p_float": 202.2,
                "p_int": 202,
                "p_list_int": [
                    205,
                    1,
                    202
                ],
                "p_map_text_text": {
                    "a": "V202A",
                    "b": "V202B"
                },
                "p_set_int": [
                    202,
                    402,
                    300
                ],
                "p_text": "b202",
                "p_timestamp": "1202-01-01T01:01:01.000Z"
            },
            {
                "p_ascii": "A",
                "p_bigint": 100,
                "p_boolean": false,
                "p_float": 203.2,
                "p_int": 203,
                "p_list_int": [
                    206,
                    1,
                    203
                ],
                "p_map_text_text": {
                    "a": "V203A",
                    "b": "V203B"
                },
                "p_set_int": [
                    403,
                    300,
                    203
                ],
                "p_text": "b203",
                "p_timestamp": "1203-01-01T01:01:01.000Z"
            },
            {
                "p_ascii": "A",
                "p_bigint": 100,
                "p_boolean": true,
                "p_float": 204.2,
                "p_int": 204,
                "p_list_int": [
                    207,
                    1,
                    204
                ],
                "p_map_text_text": {
                    "a": "V204A",
                    "b": "V204B"
                },
                "p_set_int": [
                    204,
                    404,
                    300
                ],
                "p_text": "b204",
                "p_timestamp": "1204-01-01T01:01:01.000Z"
            },
            {
                "p_ascii": "A",
                "p_bigint": 100,
                "p_boolean": false,
                "p_float": 205.2,
                "p_int": 205,
                "p_list_int": [
                    208,
                    1,
                    205
                ],
                "p_map_text_text": {
                    "a": "V205A",
                    "b": "V205B"
                },
                "p_set_int": [
                    205,
                    300,
                    405
                ],
                "p_text": "b205",
                "p_timestamp": "1205-01-01T01:01:01.000Z"
            },
            {
                "p_ascii": "A",
                "p_bigint": 100,
                "p_boolean": true,
                "p_float": 206.2,
                "p_int": 206,
                "p_list_int": [
                    209,
                    1,
                    206
                ],
                "p_map_text_text": {
                    "a": "V206A",
                    "b": "V206B"
                },
                "p_set_int": [
                    300,
                    206,
                    406
                ],
                "p_text": "b206",
                "p_timestamp": "1206-01-01T01:01:01.000Z"
            },
            {
                "p_ascii": "A",
                "p_bigint": 100,
                "p_boolean": false,
                "p_float": 207.2,
                "p_int": 207,
                "p_list_int": [
                    210,
                    1,
                    207
                ],
                "p_map_text_text": {
                    "a": "V207A",
                    "b": "V207B"
                },
                "p_set_int": [
                    207,
                    300,
                    407
                ],
                "p_text": "b207",
                "p_timestamp": "1207-01-01T01:01:01.000Z"
            },
            {
                "p_ascii": "A",
                "p_bigint": 100,
                "p_boolean": true,
                "p_float": 208.2,
                "p_int": 208,
                "p_list_int": [
                    211,
                    1,
                    208
                ],
                "p_map_text_text": {
                    "a": "V208A",
                    "b": "V208B"
                },
                "p_set_int": [
                    408,
                    300,
                    208
                ],
                "p_text": "b208",
                "p_timestamp": "1208-01-01T01:01:01.000Z"
            },
            {
                "p_ascii": "A",
                "p_bigint": 100,
                "p_boolean": false,
                "p_float": 209.2,
                "p_int": 209,
                "p_list_int": [
                    212,
                    1,
                    209
                ],
                "p_map_text_text": {
                    "a": "V209A",
                    "b": "V209B"
                },
                "p_set_int": [
                    409,
                    300,
                    209
                ],
                "p_text": "b209",
                "p_timestamp": "1209-01-01T01:01:01.000Z"
            },
            {
                "p_ascii": "A",
                "p_bigint": 100,
                "p_boolean": true,
                "p_float": 210.2,
                "p_int": 210,
                "p_list_int": [
                    213,
                    1,
                    210
                ],
                "p_map_text_text": {
                    "a": "V210A",
                    "b": "V210B"
                },
                "p_set_int": [
                    210,
                    410,
                    300
                ],
                "p_text": "b210",
                "p_timestamp": "1210-01-01T01:01:01.000Z"
            },
            {
                "p_ascii": "A",
                "p_bigint": 100,
                "p_boolean": false,
                "p_float": 211.2,
                "p_int": 211,
                "p_list_int": [
                    214,
                    1,
                    211
                ],
                "p_map_text_text": {
                    "a": "V211A",
                    "b": "V211B"
                },
                "p_set_int": [
                    411,
                    300,
                    211
                ],
                "p_text": "b211",
                "p_timestamp": "1211-01-01T01:01:01.000Z"
            },
            {
                "p_ascii": "A",
                "p_bigint": 100,
                "p_boolean": true,
                "p_float": 212.2,
                "p_int": 212,
                "p_list_int": [
                    215,
                    1,
                    212
                ],
                "p_map_text_text": {
                    "a": "V212A",
                    "b": "V212B"
                },
                "p_set_int": [
                    212,
                    412,
                    300
                ],
                "p_text": "b212",
                "p_timestamp": "1212-01-01T01:01:01.000Z"
            },
            {
                "p_ascii": "A",
                "p_bigint": 100,
                "p_boolean": false,
                "p_float": 213.2,
                "p_int": 213,
                "p_list_int": [
                    216,
                    1,
                    213
                ],
                "p_map_text_text": {
                    "a": "V213A",
                    "b": "V213B"
                },
                "p_set_int": [
                    213,
                    300,
                    413
                ],
                "p_text": "b213",
                "p_timestamp": "1213-01-01T01:01:01.000Z"
            },
            {
                "p_ascii": "A",
                "p_bigint": 100,
                "p_boolean": true,
                "p_float": 214.2,
                "p_int": 214,
                "p_list_int": [
                    217,
                    1,
                    214
                ],
                "p_map_text_text": {
                    "a": "V214A",
                    "b": "V214B"
                },
                "p_set_int": [
                    300,
                    214,
                    414
                ],
                "p_text": "b214",
                "p_timestamp": "1214-01-01T01:01:01.000Z"
            },
            {
                "p_ascii": "A",
                "p_bigint": 100,
                "p_boolean": false,
                "p_float": 215.2,
                "p_int": 215,
                "p_list_int": [
                    218,
                    1,
                    215
                ],
                "p_map_text_text": {
                    "a": "V215A",
                    "b": "V215B"
                },
                "p_set_int": [
                    215,
                    300,
                    415
                ],
                "p_text": "b215",
                "p_timestamp": "1215-01-01T01:01:01.000Z"
            },
            {
                "p_ascii": "A",
                "p_bigint": 100,
                "p_boolean": true,
                "p_float": 216.2,
                "p_int": 216,
                "p_list_int": [
                    219,
                    1,
                    216
                ],
                "p_map_text_text": {
                    "a": "V216A",
                    "b": "V216B"
                },
                "p_set_int": [
                    416,
                    300,
                    216
                ],
                "p_text": "b216",
                "p_timestamp": "1216-01-01T01:01:01.000Z"
            },
            {
                "p_ascii": "A",
                "p_bigint": 100,
                "p_boolean": false,
                "p_float": 217.2,
                "p_int": 217,
                "p_list_int": [
                    220,
                    1,
                    217
                ],
                "p_map_text_text": {
                    "a": "V217A",
                    "b": "V217B"
                },
                "p_set_int": [
                    417,
                    300,
                    217
                ],
                "p_text": "b217",
                "p_timestamp": "1217-01-01T01:01:01.000Z"
            },
            {
                "p_ascii": "A",
                "p_bigint": 100,
                "p_boolean": true,
                "p_float": 218.2,
                "p_int": 218,
                "p_list_int": [
                    221,
                    1,
                    218
                ],
                "p_map_text_text": {
                    "a": "V218A",
                    "b": "V218B"
                },
                "p_set_int": [
                    218,
                    418,
                    300
                ],
                "p_text": "b218",
                "p_timestamp": "1218-01-01T01:01:01.000Z"
            },
            {
                "p_ascii": "A",
                "p_bigint": 100,
                "p_boolean": false,
                "p_float": 219.2,
                "p_int": 219,
                "p_list_int": [
                    222,
                    1,
                    219
                ],
                "p_map_text_text": {
                    "a": "V219A",
                    "b": "V219B"
                },
                "p_set_int": [
                    419,
                    300,
                    219
                ],
                "p_text": "b219",
                "p_timestamp": "1219-01-01T01:01:01.000Z"
            },
            {
                "p_ascii": "A",
                "p_bigint": 100,
                "p_boolean": true,
                "p_float": 220.2,
                "p_int": 220,
                "p_list_int": [
                    223,
                    1,
                    220
                ],
                "p_map_text_text": {
                    "a": "V220A",
                    "b": "V220B"
                },
                "p_set_int": [
                    220,
                    420,
                    300
                ],
                "p_text": "b220",
                "p_timestamp": "1220-01-01T01:01:01.000Z"
            },
            {
                "p_ascii": "A",
                "p_bigint": 100,
                "p_boolean": false,
                "p_float": 221.2,
                "p_int": 221,
                "p_list_int": [
                    224,
                    1,
                    221
                ],
                "p_map_text_text": {
                    "a": "V221A",
                    "b": "V221B"
                },
                "p_set_int": [
                    221,
                    300,
                    421
                ],
                "p_text": "b221",
                "p_timestamp": "1221-01-01T01:01:01.000Z"
            },
            {
                "p_ascii": "A",
                "p_bigint": 100,
                "p_boolean": true,
                "p_float": 222.2,
                "p_int": 222,
                "p_list_int": [
                    225,
                    1,
                    222
                ],
                "p_map_text_text": {
                    "a": "V222A",
                    "b": "V222B"
                },
                "p_set_int": [
                    300,
                    222,
                    422
                ],
                "p_text": "b222",
                "p_timestamp": "1222-01-01T01:01:01.000Z"
            },
            {
                "p_ascii": "A",
                "p_bigint": 100,
                "p_boolean": false,
                "p_float": 223.2,
                "p_int": 223,
                "p_list_int": [
                    226,
                    1,
                    223
                ],
                "p_map_text_text": {
                    "a": "V223A",
                    "b": "V223B"
                },
                "p_set_int": [
                    223,
                    300,
                    423
                ],
                "p_text": "b223",
                "p_timestamp": "1223-01-01T01:01:01.000Z"
            },
            {
                "p_ascii": "A",
                "p_bigint": 100,
                "p_boolean": true,
                "p_float": 224.2,
                "p_int": 224,
                "p_list_int": [
                    227,
                    1,
                    224
                ],
                "p_map_text_text": {
                    "a": "V224A",
                    "b": "V224B"
                },
                "p_set_int": [
                    424,
                    224,
                    300
                ],
                "p_text": "b224",
                "p_timestamp": "1224-01-01T01:01:01.000Z"
            },
            {
                "p_ascii": "A",
                "p_bigint": 100,
                "p_boolean": false,
                "p_float": 225.2,
                "p_int": 225,
                "p_list_int": [
                    228,
                    1,
                    225
                ],
                "p_map_text_text": {
                    "a": "V225A",
                    "b": "V225B"
                },
                "p_set_int": [
                    425,
                    300,
                    225
                ],
                "p_text": "b225",
                "p_timestamp": "1225-01-01T01:01:01.000Z"
            },
            {
                "p_ascii": "A",
                "p_bigint": 100,
                "p_boolean": true,
                "p_float": 226.2,
                "p_int": 226,
                "p_list_int": [
                    229,
                    1,
                    226
                ],
                "p_map_text_text": {
                    "a": "V226A",
                    "b": "V226B"
                },
                "p_set_int": [
                    426,
                    226,
                    300
                ],
                "p_text": "b226",
                "p_timestamp": "1226-01-01T01:01:01.000Z"
            },
            {
                "p_ascii": "A",
                "p_bigint": 100,
                "p_boolean": false,
                "p_float": 227.2,
                "p_int": 227,
                "p_list_int": [
                    230,
                    1,
                    227
                ],
                "p_map_text_text": {
                    "a": "V227A",
                    "b": "V227B"
                },
                "p_set_int": [
                    427,
                    300,
                    227
                ],
                "p_text": "b227",
                "p_timestamp": "1227-01-01T01:01:01.000Z"
            },
            {
                "p_ascii": "A",
                "p_bigint": 100,
                "p_boolean": true,
                "p_float": 228.2,
                "p_int": 228,
                "p_list_int": [
                    231,
                    1,
                    228
                ],
                "p_map_text_text": {
                    "a": "V228A",
                    "b": "V228B"
                },
                "p_set_int": [
                    428,
                    228,
                    300
                ],
                "p_text": "b228",
                "p_timestamp": "1228-01-01T01:01:01.000Z"
            },
            {
                "p_ascii": "A",
                "p_bigint": 100,
                "p_boolean": false,
                "p_float": 229.2,
                "p_int": 229,
                "p_list_int": [
                    232,
                    1,
                    229
                ],
                "p_map_text_text": {
                    "a": "V229A",
                    "b": "V229B"
                },
                "p_set_int": [
                    229,
                    300,
                    429
                ],
                "p_text": "b229",
                "p_timestamp": "1229-01-01T01:01:01.000Z"
            },
            {
                "p_ascii": "A",
                "p_bigint": 100,
                "p_boolean": true,
                "p_float": 230.2,
                "p_int": 230,
                "p_list_int": [
                    233,
                    1,
                    230
                ],
                "p_map_text_text": {
                    "a": "V230A",
                    "b": "V230B"
                },
                "p_set_int": [
                    300,
                    430,
                    230
                ],
                "p_text": "b230",
                "p_timestamp": "1230-01-01T01:01:01.000Z"
            },
            {
                "p_ascii": "A",
                "p_bigint": 100,
                "p_boolean": false,
                "p_float": 231.2,
                "p_int": 231,
                "p_list_int": [
                    234,
                    1,
                    231
                ],
                "p_map_text_text": {
                    "a": "V231A",
                    "b": "V231B"
                },
                "p_set_int": [
                    231,
                    300,
                    431
                ],
                "p_text": "b231",
                "p_timestamp": "1231-01-01T01:01:01.000Z"
            },
            {
                "p_ascii": "A",
                "p_bigint": 100,
                "p_boolean": true,
                "p_float": 232.2,
                "p_int": 232,
                "p_list_int": [
                    235,
                    1,
                    232
                ],
                "p_map_text_text": {
                    "a": "V232A",
                    "b": "V232B"
                },
                "p_set_int": [
                    432,
                    232,
                    300
                ],
                "p_text": "b232",
                "p_timestamp": "1232-01-01T01:01:01.000Z"
            },
            {
                "p_ascii": "A",
                "p_bigint": 100,
                "p_boolean": false,
                "p_float": 233.2,
                "p_int": 233,
                "p_list_int": [
                    236,
                    1,
                    233
                ],
                "p_map_text_text": {
                    "a": "V233A",
                    "b": "V233B"
                },
                "p_set_int": [
                    433,
                    300,
                    233
                ],
                "p_text": "b233",
                "p_timestamp": "1233-01-01T01:01:01.000Z"
            },
            {
                "p_ascii": "A",
                "p_bigint": 100,
                "p_boolean": true,
                "p_float": 234.2,
                "p_int": 234,
                "p_list_int": [
                    237,
                    1,
                    234
                ],
                "p_map_text_text": {
                    "a": "V234A",
                    "b": "V234B"
                },
                "p_set_int": [
                    434,
                    234,
                    300
                ],
                "p_text": "b234",
                "p_timestamp": "1234-01-01T01:01:01.000Z"
            },
            {
                "p_ascii": "A",
                "p_bigint": 100,
                "p_boolean": false,
                "p_float": 235.2,
                "p_int": 235,
                "p_list_int": [
                    238,
                    1,
                    235
                ],
                "p_map_text_text": {
                    "a": "V235A",
                    "b": "V235B"
                },
                "p_set_int": [
                    435,
                    300,
                    235
                ],
                "p_text": "b235",
                "p_timestamp": "1235-01-01T01:01:01.000Z"
            },
            {
                "p_ascii": "A",
                "p_bigint": 100,
                "p_boolean": true,
                "p_float": 236.2,
                "p_int": 236,
                "p_list_int": [
                    239,
                    1,
                    236
                ],
                "p_map_text_text": {
                    "a": "V236A",
                    "b": "V236B"
                },
                "p_set_int": [
                    436,
                    236,
                    300
                ],
                "p_text": "b236",
                "p_timestamp": "1236-01-01T01:01:01.000Z"
            },
            {
                "p_ascii": "A",
                "p_bigint": 100,
                "p_boolean": false,
                "p_float": 237.2,
                "p_int": 237,
                "p_list_int": [
                    240,
                    1,
                    237
                ],
                "p_map_text_text": {
                    "a": "V237A",
                    "b": "V237B"
                },
                "p_set_int": [
                    237,
                    300,
                    437
                ],
                "p_text": "b237",
                "p_timestamp": "1237-01-01T01:01:01.000Z"
            },
            {
                "p_ascii": "A",
                "p_bigint": 100,
                "p_boolean": true,
                "p_float": 238.2,
                "p_int": 238,
                "p_list_int": [
                    241,
                    1,
                    238
                ],
                "p_map_text_text": {
                    "a": "V238A",
                    "b": "V238B"
                },
                "p_set_int": [
                    300,
                    438,
                    238
                ],
                "p_text": "b238",
                "p_timestamp": "1238-01-01T01:01:01.000Z"
            },
            {
                "p_ascii": "A",
                "p_bigint": 100,
                "p_boolean": false,
                "p_float": 239.2,
                "p_int": 239,
                "p_list_int": [
                    242,
                    1,
                    239
                ],
                "p_map_text_text": {
                    "a": "V239A",
                    "b": "V239B"
                },
                "p_set_int": [
                    239,
                    300,
                    439
                ],
                "p_text": "b239",
                "p_timestamp": "1239-01-01T01:01:01.000Z"
            },
            {
                "p_ascii": "A",
                "p_bigint": 100,
                "p_boolean": true,
                "p_float": 240.2,
                "p_int": 240,
                "p_list_int": [
                    243,
                    1,
                    240
                ],
                "p_map_text_text": {
                    "a": "V240A",
                    "b": "V240B"
                },
                "p_set_int": [
                    440,
                    240,
                    300
                ],
                "p_text": "b240",
                "p_timestamp": "1240-01-01T01:01:01.000Z"
            },
            {
                "p_ascii": "A",
                "p_bigint": 100,
                "p_boolean": false,
                "p_float": 241.2,
                "p_int": 241,
                "p_list_int": [
                    244,
                    1,
                    241
                ],
                "p_map_text_text": {
                    "a": "V241A",
                    "b": "V241B"
                },
                "p_set_int": [
                    441,
                    300,
                    241
                ],
                "p_text": "b241",
                "p_timestamp": "1241-01-01T01:01:01.000Z"
            },
            {
                "p_ascii": "A",
                "p_bigint": 100,
                "p_boolean": true,
                "p_float": 242.2,
                "p_int": 242,
                "p_list_int": [
                    245,
                    1,
                    242
                ],
                "p_map_text_text": {
                    "a": "V242A",
                    "b": "V242B"
                },
                "p_set_int": [
                    442,
                    242,
                    300
                ],
                "p_text": "b242",
                "p_timestamp": "1242-01-01T01:01:01.000Z"
            },
            {
                "p_ascii": "A",
                "p_bigint": 100,
                "p_boolean": false,
                "p_float": 243.2,
                "p_int": 243,
                "p_list_int": [
                    246,
                    1,
                    243
                ],
                "p_map_text_text": {
                    "a": "V243A",
                    "b": "V243B"
                },
                "p_set_int": [
                    443,
                    300,
                    243
                ],
                "p_text": "b243",
                "p_timestamp": "1243-01-01T01:01:01.000Z"
            },
            {
                "p_ascii": "A",
                "p_bigint": 100,
                "p_boolean": true,
                "p_float": 244.2,
                "p_int": 244,
                "p_list_int": [
                    247,
                    1,
                    244
                ],
                "p_map_text_text": {
                    "a": "V244A",
                    "b": "V244B"
                },
                "p_set_int": [
                    444,
                    244,
                    300
                ],
                "p_text": "b244",
                "p_timestamp": "1244-01-01T01:01:01.000Z"
            },
            {
                "p_ascii": "A",
                "p_bigint": 100,
                "p_boolean": false,
                "p_float": 245.2,
                "p_int": 245,
                "p_list_int": [
                    248,
                    1,
                    245
                ],
                "p_map_text_text": {
                    "a": "V245A",
                    "b": "V245B"
                },
                "p_set_int": [
                    245,
                    300,
                    445
                ],
                "p_text": "b245",
                "p_timestamp": "1245-01-01T01:01:01.000Z"
            },
            {
                "p_ascii": "A",
                "p_bigint": 100,
                "p_boolean": true,
                "p_float": 246.2,
                "p_int": 246,
                "p_list_int": [
                    249,
                    1,
                    246
                ],
                "p_map_text_text": {
                    "a": "V246A",
                    "b": "V246B"
                },
                "p_set_int": [
                    300,
                    446,
                    246
                ],
                "p_text": "b246",
                "p_timestamp": "1246-01-01T01:01:01.000Z"
            },
            {
                "p_ascii": "A",
                "p_bigint": 100,
                "p_boolean": false,
                "p_float": 247.2,
                "p_int": 247,
                "p_list_int": [
                    250,
                    1,
                    247
                ],
                "p_map_text_text": {
                    "a": "V247A",
                    "b": "V247B"
                },
                "p_set_int": [
                    247,
                    300,
                    447
                ],
                "p_text": "b247",
                "p_timestamp": "1247-01-01T01:01:01.000Z"
            },
            {
                "p_ascii": "A",
                "p_bigint": 100,
                "p_boolean": true,
                "p_float": 248.2,
                "p_int": 248,
                "p_list_int": [
                    251,
                    1,
                    248
                ],
                "p_map_text_text": {
                    "a": "V248A",
                    "b": "V248B"
                },
                "p_set_int": [
                    448,
                    248,
                    300
                ],
                "p_text": "b248",
                "p_timestamp": "1248-01-01T01:01:01.000Z"
            },
            {
                "p_ascii": "A",
                "p_bigint": 100,
                "p_boolean": false,
                "p_float": 249.2,
                "p_int": 249,
                "p_list_int": [
                    252,
                    1,
                    249
                ],
                "p_map_text_text": {
                    "a": "V249A",
                    "b": "V249B"
                },
                "p_set_int": [
                    449,
                    300,
                    249
                ],
                "p_text": "b249",
                "p_timestamp": "1249-01-01T01:01:01.000Z"
            }
        ],
        "options": {
            "ordered": false
        }
    }
}

first find

{
    "find": {
        "filter": {
            "p_ascii": "A",
            "p_bigint": 100
        },
        "options": {
            "limit": 251
        },
        "sort": {
            "p_int": -1
        }
    }
}

Observe a nextPageState in the response

next find

Use the nextPageState in a new find:

{
    "find": {
        "filter": {
            "p_ascii": "A",
            "p_bigint": 100
        },
        "options": {
            "limit": 251,
            "pageState": "AAgABAAAAOYBAYDn8H///+s="
        },
        "sort": {
            "p_int": -1
        }
    }
}

(Errorful) response looks like this:

{
    "errors": [
        {
            "message": "Request invalid: field 'command.options.pageState' value \"FindCommand[filterClause=FilterClause[logicalExpression=LogicalExpression{logicalRelation='AND', totalComparisonExpressionCount=2, logicalExpressions=[], comparisonExpressions=[ComparisonExpression{path='p_ascii', filterOperations=[ValueComparisonOperation[operator=EQ, operand=JsonLiteral{type=STRING, value(String)=A}]], dbFilters=null}, ComparisonExpression{path='p_bigint', filterOperations=[ValueComparisonOperation[operator=EQ, operand=JsonLiteral{type=NUMBER, value(BigDecimal)=100}]], dbFilters=null}]}], projectionDefinition=null, sortClause=SortClause[sortExpressions=[SortExpression[path=p_int, ascending=false, vector=null, vectorize=null]]], options=Options[limit=251, skip=null, pageState=AAgABAAAAOYBAYDn8H///+s=, includeSimilarity=false, includeSortVector=false]]\" not valid. Problem: pageState is not supported with sort clause.",
            "errorCode": "COMMAND_FIELD_INVALID",
            "id": "f5bd6d94-53f1-455e-ba32-3d368e49cec4",
            "family": "REQUEST",
            "title": "Request invalid",
            "scope": "EMPTY"
        }
    ]
}