Append to nested type object

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.

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