I would like to check whether a node exists using its name (instead of its ID). The Cypher query looks like :
MATCH (c:Jaguar{name:"JLR 2.5Ltr"})-[:REPRESENTED_BY]->(v) RETURN c IS NOT NULL
However, Using neo4j shell/web console, the result returned is of type String. The same fails in spring-data-neo4j with error :
Null return value from advice does not match primitive return type for: public abstract boolean xxx.yyy.repository.SomeRepository.checkIfDatasetExists(java.lang.String)
Has somebody come across any work around for this
Return all elements When you want to return all nodes, relationships and paths found in a query, you can use the * symbol.
(b) Use Neo4j, by creating a node per key-value setting the key and value as properties on the node, but there is no relationship other then having an index to group these nodes together, exposing the key of the key-value as the key on the index.
You can change the nodes associated with a label but you can't change the type of a relationship. Conceptually, if you take your chicken out of one coop and put it in another you haven't altered the substance of the chicken.
The WITH clause allows query parts to be chained together, piping the results from one to be used as starting points or criteria in the next. It is important to note that WITH affects variables in scope.
The answer provided by Supamiu will not work unfortunately, you need to hack this by returning a count expression :
MATCH (c:Jaguar{name:"JLR 2.5Ltr"})-[:REPRESENTED_BY]->(v)
RETURN count(c) > 0 as c
You should use CASE to check if your node is null or not, and return the value you need :
MATCH (c:Jaguar{name:"JLR 2.5Ltr"})-[:REPRESENTED_BY]->(v)
RETURN CASE WHEN c IS NULL THEN false ELSE true END as c
More informations can be found on Neo4j's Documentation
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With