Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to query for properties with dashes in Neo4j using Cypher

Tags:

neo4j

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.

like image 402
net_j Avatar asked Feb 15 '13 00:02

net_j


People also ask

WHAT IS WITH clause in Cypher?

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.

Can relationships have properties in Neo4j?

The Neo4j Graph Data Science Library provides multiple operations to work with relationships and their properties stored in a projected graphs. Relationship properties are either added during the graph projection or when using the mutate mode of our graph algorithms.


1 Answers

Escape the property with backticks:

String query = "start n=node(*) where (n.`property-id` = 'someid') return ID(n)"
like image 199
Luanne Avatar answered Sep 24 '22 10:09

Luanne