Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is It Possible for a Label or Property Name to Include Spaces?

Tags:

neo4j

I'd like to use labels / properties that include spaces rather than CamelCase. Is this possible and if so how?

e.g. 'Architecture Description Element'

like image 656
wikitect Avatar asked Aug 12 '15 08:08

wikitect


1 Answers

Yes you can, but you need to surround the label or property name with backticks.

CREATE (n:`Architecture Description Element` { `property name`:"It works!" })

http://console.neo4j.org/r/kctf37

The manual section 2.1 says

Label names

Any non-empty Unicode string can be used as a label name. In Cypher, you may need to use the backtick (`) syntax to avoid clashes with Cypher identifier rules or to allow non-alphanumeric characters in a label. By convention, labels are written with CamelCase notation, with the first letter in upper case. For instance, User or CarOwner.

The corresponding paragraph about properties doesn't speak to property name restrictions, but in the Cypher chapter there is a passage about identifier names in section 9.3 that says

Identifier names are case sensitive, and can contain underscores and alphanumeric characters (a-z, 0-9), but must always start with a letter. If other characters are needed, you can quote the identifier using backquote (`) signs.

The same rules apply to property names.

If you use the dump command from the shell to export a subgraph all property and label names will be surrounded by backticks, whether they need it or not. You may want to consider doing same for programmatically generated queries.

like image 72
jjaderberg Avatar answered Sep 28 '22 10:09

jjaderberg