I’m getting results from several topics using the # function at the end of my topic path-tree.
e.g. ‘~/Installations/Location/Vessel/Seapath/#’
where ‘~/Installations/Location/Vessel/Seapath/acceleration_x’ is an example path
The problem now is that: when I get “context.topic” I get the full path (~/Installations/Location/Vessel/Seapath/acceleration_x) instead of the last path (acceleration_x) and I can’t seem to find a way to extract only the last path as there is barely any functionality in Functions | Cognite Documentation.
Is there a way to get past this?
sample data: {"timestamp":1700740159863,"values":[-0.013358482159674168]}
here is my transformation:
{
"externalId": concat("installation.vessel.seapath.", context.topic_last_part), # where I can e.g. do split, substring, slice, regexp_extract or any string manipulation on context.topic
"timestamp": input.timestamp,
"value": input.values[0],
"type": "datapoint"
}
sample output;
{
"externalId": "installation.vessel.seapath.acceleration_x",
"timestamp": 1700740159863,
"type": "datapoint",
"value": -0.013358482159674168
}
Check the
documentation
Ask the
Community
Take a look
at
Academy
Cognite
Status
Page
Contact
Cognite Support