Bulk Update with ScriptedUpsert run scripts twice

I'm trying to use scripted upsert to handle array of nested field. Basically on each insert/update, we need to append new version into the nested field. The following is the script:

if (ctx._source[params.version_name] == null)
{
        ctx._source[params.version_name] = new ArrayList();
}
ctx._source[params.version_name].add(params.Versions);

There is one specific instance whereby first insertion results in 2 versions being inserted. it seems like the script is being evaluated twice. And on bulk insert of 100 documents, it only happens on first document (the rest of them have the correct behavior, i.e. only one version being appended).

I can't find any similar bug so far, any idea what's going on? or any hints on how to debug painless? this scripting approach seems to be very blackbox once bug appears.

Additional information:
Elasticsearch 7.1.1 with golang client from https://github.com/olivere/elastic

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.