# Append to nested type object

**URL:** https://discuss.elastic.co/t/append-to-nested-type-object/88518
**Category:** Elasticsearch
**Created:** [June 7, 2017, 7:21am UTC](https://discuss.elastic.co/t/append-to-nested-type-object/88518 "2017-06-07T07:21:47Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![waynesmallman](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/waynesmallman/32/18596_2.png) [@waynesmallman](https://discuss.elastic.co/u/waynesmallman)
#### Post date: [June 7, 2017, 7:21am UTC](https://discuss.elastic.co/t/append-to-nested-type-object/88518/1 "2017-06-07T07:21:48Z")

</div>

Hi, I'm attempting to append a nested type object.

I'm using the official PHP libraries for Elasticsearch.

In the controller, I have:

```
$data = [
	'note_link_id' => $link_id,
	'user_id' => $this->flexi_auth->get_user_id(),
	'creation' => date('Y-m-d\TH:i:s'),
	'modification' => date('Y-m-d\TH:i:s'),
	'from_asset' => $from,
	'to_asset' => $to
];

$parameters = array(
	'index' => "asset",
	'type' => $this->getAssetType( $from_note ),
	'id' => $from_note->note_id
);

$this->elasticsearch_model->addAssetLinkData( $data, $parameters );

```

In the model, I have:

```
public function addAssetLinkData ($data, $params) {
	try {
		if (!isset($params['index']) || !isset($params['type']))
			die ("Unable to add Elastic index for an Asset Link. Either index or type is not defined.");

		$client = $this->_client;

		$params['body']['doc']['links'][] = $data;

		$responses = $client->update($params);
	} catch (Exception $e) {
		//die($e->getMessage());
	}
}

```

However, instead of appending the object, it replaces everything that's already in there.

I've tried an endless number of variations in the model, which either don't execute, execute wrong, or replace everything that's already in there.

Some advice would be much appreciated.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [July 5, 2017, 7:21am UTC](https://discuss.elastic.co/t/append-to-nested-type-object/88518/2 "2017-07-05T07:21:48Z")

</div>

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