user2298327
user2298327

Reputation: 1

EntityNotFoundException while firing a cypher

I am newbie to neo4j and I really need help.

I have created nodes properties NAME, EMAIL and AGE. These nodes are having relationship: IS_FRIEND_OF with property SINCE with other nodes.

I have given property values in NAME as “A”, “B”, “C”, “D” and so on.

Now when I fire a query in console like: Start n=node(*) where n.NAME=’A’ return n;

It is giving an exception like: EntityNotFoundException: The property 'NAME' does not exist on Node[0]

Now if I add a property NAME = “” on node [0] and then fire the same query, it is providing the correct output. For small data set it can work but for larger ones specifying each property for node [0] doesn’t seems to be the good solution.

Is it the only workaround or something else and better can be applied?

Upvotes: 0

Views: 301

Answers (2)

Mohamed Ismail Mansour
Mohamed Ismail Mansour

Reputation: 1053

Cypher has two special operators: ? and ! to use in this case to handle this exception

Using ? will evaluate to true if n.prop is missing:

START n=node(*) WHERE n.NAME? = "A" RETURN n

And using ! will evaluate to false if n.prop is missing:

START n=node(*) WHERE n.NAME! = "A" RETURN n

Upvotes: 1

tstorms
tstorms

Reputation: 5001

STARTn=node(*) WHERE n.NAME! = "A" RETURN n

The exclamation mark will do the following:

TRUE if n.prop = value, FALSE if n is NULL or n.prop does not exist

Upvotes: 1

Related Questions