3

I am new to neo4j, so my question may sound stupid to you but anyway.

I have OSM data set imported to neo4j graph db. So curretnly I am trying to query different stuff from db, like:

MATCH (a) WHERE has(a.addr:street) RETURN a.addr:street

and it fails with an sysntax error:

Type mismatch: expected Node but was Boolean, Number, String or Collection<Any> (line 1, column 23)
"MATCH (a) WHERE has(a.addr:street) RETURN a.addr:street"
                       ^

Which is strange, as the nodes has a lot of properties with colons(:).

Does anybody know how can I query such properties?

Mureinik
  • 297,002
  • 52
  • 306
  • 350
Taras Shchybovyk
  • 416
  • 4
  • 17

2 Answers2

2

Welcome to Neo4j! Characters like : or whitespace can introduce ambiguity in a query since they may be significant in the query language, which gives the parser hick ups. You can still use these characters by enclosing the expression in "backticks", i.e.

MATCH (a) WHERE has(a.`addr:street`) RETURN a.`addr:street`

You can see some other examples here.

jjaderberg
  • 9,844
  • 34
  • 34
  • Thanks, it works. But I am seeing weird thing: this query is not working from new web UI shell (2.0). I am getting 'Invalid input ''': expected whitespace or an identifier (line 1, column 29)' error. But as for shell everything works properly. – Taras Shchybovyk Nov 18 '13 at 14:25
  • You have to use backticks: [`\``], not single quote: [']. (Same character as is used on StackOverflow for posting short code snippets.) – jjaderberg Nov 18 '13 at 18:39
0

There are three parts of a cypher query:

START,MATCH AND RETURN. So your query here will be ::

START a=node(1)
MATCH (a)-[:HAS]->(addr)-[:HAS]->(street)
RETURN street
dev
  • 715
  • 5
  • 21
  • Probably I explained bad. The problem is that nodes in db contains properties like (key=addr:street, value=Rennweg). So I cant query nodes with such property notations. If a.addr:street will be substituted to a.name - everything is ok. – Taras Shchybovyk Nov 18 '13 at 14:17