Skip to content

[BUG] Slicing search with searchAfter serialize date as string insted of number #427

@d31m07y1988

Description

@d31m07y1988

What is the bug?

Slicing search with searchAfter serialize date as string insted of number.

        <dependency>
            <groupId>org.opensearch.client</groupId>
            <artifactId>spring-data-opensearch-starter</artifactId>
            <version>1.5.0</version>
            <!--https://github.com/opensearch-project/spring-data-opensearch/issues/121-->
            <exclusions>
                <exclusion>
                    <groupId>org.opensearch.client</groupId>
                    <artifactId>opensearch-rest-client-sniffer</artifactId>
                </exclusion>

                <!-- disable to use opensearch java client-->
                <exclusion>
                    <groupId>org.opensearch.client</groupId>
                    <artifactId>opensearch-rest-high-level-client</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>org.opensearch.client</groupId>
            <artifactId>opensearch-java</artifactId>
            <version>2.19.0</version>
        </dependency>

I have a query

var query = new CriteriaQueryBuilder(criteria)
                .withMaxResults(1)
                .withSort(Sort.by(List.of(
                        Sort.Order.desc("endedAt"),
                        Sort.Order.desc("id"))))
                .withSearchAfter(List.of(doc.getEndedAt().toInstant().toEpochMilli(), doc.getId()))
                .withTrackTotalHits(false)
                .build();
operations.search(query, LogDocument.class)

so in this configuration final request looks like


    "search_after": [
        "1684342681000",
        "01951433-a550-717a-9108-4cbd2f4cad3c"
    ],
    "size": 1,
    "sort": [
        {
            "endedAt": {
                "mode": "max",
                "order": "desc"
            }
        },
        {
            "id": {
                "mode": "max",
                "order": "desc"
            }
        }
    ],

insted of date like number with standard opensearch-rest-high-level-client


    "sort": [
        {
            "endedAt": {
                "order": "desc",
                "mode": "min"
            }
        },
        {
            "id": {
                "order": "desc",
                "mode": "min"
            }
        }
    ],
    "track_total_hits": -1,
    "search_after": [
        1684342681000,
        "01951433-a550-717a-9108-4cbd2f4cad3c"
    ]

with string value I get exception
Request failed: [search_phase_execution_exception] all shards failed

In search result, before pagination returnd array for sear_after also write date timestamp as string.

How can one reproduce the bug?

Do the search

What is the expected behavior?

Number serialized like number, not String.

What is your host/environment?

Do you have any screenshots?

Do you have any additional context?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions