net_j
net_j

Reputation: 205

How to query for properties with dashes in Neo4j using Cypher

I am trying to query for properties in Neo4j using the Cypher Query API. The query I am attempting is as follows:

String query = "start n=node(*) where (n.property-id = 'someid') return ID(n)"

I get an error when executing as follows: Exception in thread "main" Unknown identifier id.

So, this means that Neo4j is treating the dash in property-id as a keyword. How does one go about formulating queries with dashes in a node/relationship property?

Thank you.

Upvotes: 8

Views: 2415

Answers (1)

Luanne
Luanne

Reputation: 19373

Escape the property with backticks:

String query = "start n=node(*) where (n.`property-id` = 'someid') return ID(n)"

Upvotes: 20

Related Questions