cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Is there a way to find a node that has a property with a given value?

Will appreciate your help if you advise me how to solve this question - How do I find a node, that I know a property value of, but don't knot the property name?

For example, I know there is a node with some property value "Richie" and I want to find this node

1 ACCEPTED SOLUTION

This is a tricky one. Be aware that a query for this won't use any indexes, as you don't know the property to use.

Here's an example of how to do this using keys(node) to get the property keys, and node[key] to do dynamic property access given a string variable for the property name (that we obtain from keys()):

MATCH (p:Person)
WHERE any(key in keys(p) WHERE p[key] = 'Keanu Reeves')
RETURN p

View solution in original post

3 REPLIES 3

This is a tricky one. Be aware that a query for this won't use any indexes, as you don't know the property to use.

Here's an example of how to do this using keys(node) to get the property keys, and node[key] to do dynamic property access given a string variable for the property name (that we obtain from keys()):

MATCH (p:Person)
WHERE any(key in keys(p) WHERE p[key] = 'Keanu Reeves')
RETURN p

Thank you so much for your help, Andrew! Totally solves it!

It's not very efficient though .9