Upserting field doesn't work with elasticsearch-php

sentence in elasticsearch-php 6.0:

This means an upsert will attempt to run your update script, but if the document does not exist (or the field you are trying to update doesn’t exist), default values will be inserted instead.

when i try to upsert a field to existing document, it doesn't work and return a null_pointer_exception. Attempt with curl returns the same result.

Elasticsearch Reference [6.1] doesn't mention that upserting a field is available. maybe there is a version problem. There is no Elasticsearch-PHP [6.1] !!

Example from The Reference:

curl -XPOST 'localhost:9200/test/type1/1/_update?pretty' -H 'Content-Type: application/json' -d'
{
    "script" : {
        "source": "ctx._source.ava += params.count",
        "lang": "painless",
        "params" : {
            "count" : 4
        }
    },
    "upsert" : {
        "ava" : 1
    }
}
'

Doesn't work when the document exists and field 'ava' absents.

So, the problem is how to upsert a field to an existing document? curl example is ok, thanks.

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