Is it possible to SET a property on node and REMOVE it within a single cypher query without causing an actual disk write in Neo4j.
For example, I tried duplicating the n node in this query using n as errand but a SET on errand results to a SET on n and equally the REMOVE such the property is lost in the return value.
This is sort of my attempt at creating a transient property on a node.
String q = "MATCH (owner)-[:POSTED]->n WITH owner, n, n as errand,
CASE WHEN owner-[:RECOMMENDED]->n THEN 'BROADCASTED'
WHEN owner-[:POSTED]->n THEN 'POSTED'
WHEN owner-[:GOT_NOMINATED]->n THEN 'NOMINATED'
ELSE 'CONNECTED'
END AS relationship
SET errand.meta = relationship
REMOVE n.meta
RETURN errand LIMIT 1";
However, when ever I check my domain object to see if the property was set by Neo4j, it returns null.
public class Errand {
private String meta;
Boolean isMetaSet () {
return meta != null;
}
}
Using SDN Neo4j I get my errand object like.
Errand single = template.query(q, null).to(Errand.class).singleOrNull();
System.out.println (single.isMetaSet());
returns false.
Is the answer in Neo4J create temp variable within Cypher applicable for Nodes?
I am currently using Neo4j in Embedded Mode with Neo4j, and my queries are run using the Neo4jTemplate class.
See the response to a similar question I asked on this issue at Set a transient property on a node neo4j
n
twice, once to itself, once toerrand
in the WITH block? – FrobberOfBits