Skip to content

UpdateOperation didn't serialize the script into the request body. #779

Open

Description

Java API client version

8.13.2

Java version

17

Elasticsearch Version

8.11.3

Problem description

I use some code like below to a script execution request in the bulk update operation.

    var builder = new BulkRequest.Builder().index(index);
    for (T t : list) {
        final var uo = new UpdateOperation.Builder<Map<String, String>, T>().index(index).retryOnConflict(3);
        final var id = documentId.documentId(t);
        if (id != null) {
            uo.id(id);
        }

        // Using script
        final var ac = UpdateAction.<Map<String, String>, T>of(a -> a.scriptedUpsert(true)
                .upsert(emptyMap())
                .script(Script.of(s -> s.stored(ss -> ss.id(scriptId)
                        .params("version", JsonData.of(System.currentTimeMillis()))
                        .params("data", JsonData.of(t))))));
        UpdateOperation<Map<String, String>, T> up = uo.action(ac).build();
        builder.operations(new BulkOperation.Builder().update(up).build());
    }

    BulkRequest request = builder.build();

The action part didn't get serialized into the final request body.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions