简体   繁体   中英

Creating relationship between two previously disconnected nodes

Given query:

start n=node(*)
match p:Person, b:Book
where p.name = 'John' AND b.title = 'KJV'
create p-[r:OWNS]->b
return r

error: Expected return clause is thrown, with a caret pointing at the S]

What is the syntactical error?

May be you are using older version of Neo4j (< 2.0) which doesn't support Labels. I was able to successfully create the relationships using the below Cypher. Tried it on console.neo4j.org

CREATE (n:Person { name : 'John' })
CREATE (n:Book { title : 'KJV' })
start n=node(*)
match p:Person, b:Book
where p.name = 'John' AND b.title = 'KJV'
create p-[r:OWNS]->b
return r

EDIT

As I've guessed, you are using 1.9.2 which doesn't support Labels. You however are using the Neo4j 2.0 syntax with Labels ( p:Person , b:Book )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM