Can't query properties with colon

与世无争的帅哥 提交于 2019-12-10 22:13:33

问题


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?


回答1:


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.




回答2:


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


来源:https://stackoverflow.com/questions/20048882/cant-query-properties-with-colon

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!