cancel
Showing results for 
Search instead for 
Did you mean: 

Create node with spaces in the name via neo4j browser

CD007
Node Link

Hi

I'm trying to create a node but having trouble with the spaces - what should I do to resolve - its not clear what should have quotes. It loads fine if there is a single word for the node name?

CREATE (n:Air Plenum {id: '1', name: "Air Plenum", parent: 'hvac-Equipment', alternative: 'None', description: 'A component of the HVAC that receives air from the air handling unit or room to distribute or exhaust to or from the building.'})

CD007_0-1667213324785.png

 

Thanks

Chris

 

1 ACCEPTED SOLUTION

glilienfield
Ninja
Ninja

You are correct.  Here is the full query updated.  It now executes:

CREATE (n:`Air Plenum` {id: '1', name: "Air Plenum", parent: 'hvac-Equipment', alternative: 'None', description: 'A component of the HVAC that receives air from the air handling unit or room to distribute or exhaust to or from the building.'})

View solution in original post

8 REPLIES 8

glilienfield
Ninja
Ninja

Your label has a space.  You can enclose it in back ticks to retain the space, but I recommend not using spaces. Instead, remove the space or replace with an underscore, with preference to removing the space.

https://neo4j.com/developer/cypher/style-guide/

Thanks. when I run a query against the label from another app will it need to include the underscore or if I remove the space will it still retrieve it as I'd rather avoid having to do that additional step prior to submitting the query?

glilienfield
Ninja
Ninja

The label is being used in another app where you want to run your query?  If so, it looks like it is already been used. You can either run a script to change all the labels, or continue to use it with the space. You will need to enclose it in back ticks.  The same is true if you have property keys with spaces, or you want to alias a value with a string with spaces.  

CD007
Node Link

Thanks. What is a back tick - I'm not clear on where its meant to go?

CREATE (n:Air Plenum {id: '1', name: "Air Plenum", parent: 'hvac-Equipment', alternative: 'None', description: 'A component of the HVAC that receives air from the air handling unit or room to distribute or exhaust to or from the building.'})

It is the character that shares the key with the tilde character.  Most left key on the number row. 

Thanks so ive found the backspace and it goes here with the node name or instead of the inverted commas with the label "Air Plenum"?

CREATE (n:`Air Plenum` {id: '1', name: "Air Plenum", 

glilienfield
Ninja
Ninja

The back tick is need to enclose node kabeks, relationship types, node property names, or aliases if you want to include a space in any of those.  String literals, such as you have for the value of property ‘name’ can be enclosed in either double or single quotes. 

glilienfield
Ninja
Ninja

You are correct.  Here is the full query updated.  It now executes:

CREATE (n:`Air Plenum` {id: '1', name: "Air Plenum", parent: 'hvac-Equipment', alternative: 'None', description: 'A component of the HVAC that receives air from the air handling unit or room to distribute or exhaust to or from the building.'})