Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
02-08-2021 01:32 AM
Tried to call the apoc function using "CALL apoc.map.setKey(...)" and got an error message
This is the command I used:
MATCH (c:Car {name: 'el-camino'})
WITH properties(c) as car
CALL apoc.map.setKey(car, "maxSpeed", 150) YIELD value as carObject
RETURN carObject
and the error I got:
ERROR: Neo.ClientError.Procedure.ProcedureNotFound
There is no procedure with the name `apoc.map.setKey` registered for this database instance. Please ensure you've spelled the procedure name correctly and that the procedure is properly deployed.
I know that map.setKey is a function, is there a special way I'm missing to explicitly call functions? or to enable them? Even the autocomplete only finds procedures and not functions.
Solved! Go to Solution.
02-08-2021 09:30 AM
Thank you @dana.canzano, it does return without error but what if I don't want to call the apoc function in the RETURN line?
I want to take the properties returned from a node and add 2 more properties to that map before returning it (without saving them to the DB using SET)
I used to solve this using
WITH {color: car.color, brand: car.type...maxSpeed: someValue, weight: anotherValue} AS carObject
RETURN carObject
But this requires me to update the query whenever I change the structure of the "Car" node.
What's the best way to do that?
UPDATE
found out about apoc.map.setValues
and since I wanted to add 2 properties, it solved my immediate issue.
I still wonder whether there's a better way to do that.
02-08-2021 05:51 AM
as apoc.map.setKey us a function it should not be used with CALL
as CALL
is used when working with stored procedures.
although I'm not sure I udnerstand what you are trying to achieve but
MATCH (c:Car {name: 'el-camino'})
WITH properties(c) as car
return apoc.map.setKey(car, "maxSpeed", 150);
might be what you are after ???? or at least ^^^^ does not error out with a syntax error
02-08-2021 09:30 AM
Thank you @dana.canzano, it does return without error but what if I don't want to call the apoc function in the RETURN line?
I want to take the properties returned from a node and add 2 more properties to that map before returning it (without saving them to the DB using SET)
I used to solve this using
WITH {color: car.color, brand: car.type...maxSpeed: someValue, weight: anotherValue} AS carObject
RETURN carObject
But this requires me to update the query whenever I change the structure of the "Car" node.
What's the best way to do that?
UPDATE
found out about apoc.map.setValues
and since I wanted to add 2 properties, it solved my immediate issue.
I still wonder whether there's a better way to do that.
All the sessions of the conference are now available online