Partial update a field of nested object in list of nested object


(Prannoy Mittal) #1

Suppose i have a field list of users:

One sample document in particular index
{ "_id":100, "users" : {'name':'manu','age':20,'followers':[3,2,4]},{'name':'prannoy','age':24,'followers':[3,4,53,23,56]}}

For following use case:

Add a new entry in followers , where name is manu

For above use case:

  1. Add a new entry in followers , where name is manu
    Does elasticsearch support script over nested fields
    if users.name == "manu" then users.followes += 20 (it should update only required entry in nested users field)

Is there any other way ?


(Adrien Grand) #2

The update API is not aware of mappings, it is directly operating on the source document. Your solution sounds appropriate to me.


(system) #3