1
votes

I have Nodes in my Neo4j database that have certain properties that do not exist on all nodes, but I want to query against those properties with Cypher with a WHERE clause.

Example Data:

{id:"52", name:"Jim", age:"32", gender:"M"}
{id:"55", name:"Lisa", age:"22", gender:"F"}
{id:"97", name:"Chris", age:"38"}

Now, if I want to run a Cypher query on gender, it gives me an error on the Chris record, stating that the gender property does not exist on that node.

Example Cypher query:

START n=NODE(*) WHERE n.gender="M" RETURN n;

The specific error message I am getting is:

EntityNotFoundException: The property 'gender' does not exist on Node[4925]

I am running version 1.9.2 of Neo4j. I'd like to upgrade to 2.x and try to use labels and auto_indexes galore. But, I'm not in a position go move away from the stable release yet.

Any way to solve this with Cypher query, or with 1.9.2 indexing features?

1

1 Answers

2
votes

You can do:

WHERE n.gender! = "M"

or

WHERE has(n.gender) AND n.gender = "M"