Updating arrays on elastic App Search

I would like to know how to update arrays on Elastic App Search.

{

"Id":1,
"Keywords": { [ "test1", "test2", "test3" ] }

}

Like on the example above I would like to change the 3rd item on the array to "test4".

You'd update the field the same way you update any other non-array field. Simply POST to the document ID with the same schema field name with the updated value, and the document will be updated accordingly.

Creation:

{
  "id": "12345",
  "some_field": "old_value",
  "some_array": ["old_value"]
} 

Update:

{
  "id": "12345",
  "some_field": "new_value",
  "some_array": ["new_value"]
}

You can also PATCH if you only want to update a specific schema field instead of the entire document: Documents API | Elastic App Search Documentation [7.14] | Elastic

What about when the array have more than 1 item?

{

"id" : 1,
"some_array" : ["test1", "test2", "test3"]

}

I just want to update the second item on the array
"test2" to "test4"?

{

"id" : 1,
"some_array" : ["test1", "test4", "test3"]

}

How to do it?

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