4

How to use Integer or String with special characters as Identifier/name for a Node.

For instance I wanted to create this Node with Label as Category:

CREATE (000-116880:CATEGORY {PartnerCode:"ABCD12345", MerchantCode:"XXXX_0001", Name:"XXXX ABCDE", Leaf:1, MerchantCategoryID:125})

Or

CREATE (1234:CATEGORY {PartnerCode:"ABCD12345", MerchantCode:"XXXX_0001", Name:"XXXX ABCDE", Leaf:1, MerchantCategoryID:125})

Both these statements fail. So in short, neither am I am able to use '000-116880' as Node name nor am I able to use 1234 as Node identifier/name.

My purpose is to create Node for each category and use its Category-Code as Node name and thereafter assign relationships between categories using their category codes. So I want to have :

CREATE (000-116880:CATEGORY {PartnerCode:"ABCD12345", MerchantCode:"XXXX_0001", Name:"XXXX ABCDE", Leaf:1 ,MerchantCategoryID:125})

parent of

CREATE (000-226880:CATEGORY {PartnerCode:"ABCD12345", MerchantCode:"XXXX_0001", Name:"XXXX ABCDE", Leaf:1 ,MerchantCategoryID:225})

Can anyone please give example using Cypher statements.

jjaderberg
  • 9,844
  • 34
  • 34
user3205469
  • 995
  • 1
  • 7
  • 16

1 Answers1

3

Use backticks (`) to quote your identifier, label, property name or relationship-type.

CREATE (`000-116880`:CATEGORY
        {Leaf:1,
         MerchantCategoryID:125,
         MerchantCode:"XXXX_0001",
         Name:"XXXX ABCDE", 
         PartnerCode:"ABCD12345"})
Cans
  • 434
  • 3
  • 11
Michael Hunger
  • 41,339
  • 3
  • 57
  • 80
  • Thanks for your response Michael .. However, it does not solve my problem. For instance I use CREATE (`000-116880`:CATEGORY {PartnerCode:"ABCD12345", MerchantCode:"XXXX_0001", Name:"XXXX ABCDE", Leaf:1 ,MerchantCategoryID:125}) to create the node, neo4j still assigns an automated identifier to each node. If I now try to create relationship between 2 nodes using (`000-116880`)<-[:PARENT_OF]-(`000-116881`) Neo4j creates 2 new empty nodes and assign relationship between them . This is completely mystery for me... – user3205469 Jan 19 '14 at 12:17
  • @user3205469 Please don't put code in a comment, it's very hard to read. Instead, edit your question and add the lines from your comment to the bottom; and please format all code properly. – jjaderberg Jan 20 '14 at 16:02