Anton
Anton

Reputation: 7719

How do i turn a JSON structure with an array into unique nodes using cypher ( and py2neo )

For instance, if i have the following JSON

{people:[{name:'peter'},{name:'paul'}]}

what is the cypher syntax to create unique nodes based on 'name' with a label of 'people'?

Upvotes: 0

Views: 64

Answers (1)

Mike Holdsworth
Mike Holdsworth

Reputation: 1108

I suspect you will have to parse the string in to cypher. There is no DSL for cypher that will support your usecase that I'm aware of. Maybe you could regex the syntax based on the comma delimiter?

merge (person:People {name:{name}})  

is the basic syntax. You will also want to have a constraint on that Label to enforce uniqueness.

create constraint on (person:People) assert person.name is unique

Upvotes: 1

Related Questions